1 4 package org.oddjob.io; 5 6 import java.io.ByteArrayInputStream ; 7 import java.io.File ; 8 9 import junit.framework.TestCase; 10 11 import org.oddjob.Helper; 12 import org.oddjob.Oddjob; 13 import org.oddjob.state.JobState; 14 15 public class ExistsJobTest extends TestCase { 16 17 public void testFile() { 18 ExistsJob test = new ExistsJob(); 19 test.setFile(new File ("test/io/reference/test1.txt")); 20 test.run(); 21 assertEquals(0, test.getResult()); 22 } 23 24 public void testWild() { 25 ExistsJob test = new ExistsJob(); 26 test.setFile(new File ("test/io/reference/*.txt")); 27 test.run(); 28 assertEquals(0, test.getResult()); 29 } 30 31 public void testInOddjob() { 32 String xml = "<oddjob><exists file='test/io/reference/test1.txt'/></oddjob>"; 33 Oddjob oj = new Oddjob(); 34 oj.setInput(new ByteArrayInputStream (xml.getBytes())); 35 36 oj.run(); 37 assertEquals(JobState.COMPLETE, oj.lastJobStateEvent().getJobState()); 38 } 39 40 public void testInOddjob2() { 41 String xml = "<oddjob><exists file='idontexist.noway'/></oddjob>"; 42 Oddjob oj = new Oddjob(); 43 oj.setInput(new ByteArrayInputStream (xml.getBytes())); 44 45 oj.run(); 46 assertEquals(JobState.NOT_COMPLETE, oj.lastJobStateEvent().getJobState()); 47 } 48 49 public void testSerialize() throws Exception { 50 ExistsJob test = new ExistsJob(); 51 test.setFile(new File ("test/io/reference/test1.txt")); 52 53 ExistsJob copy = (ExistsJob) Helper.copy(test); 54 copy.run(); 55 56 assertEquals(0, copy.getResult()); 57 } 58 } 59 | Popular Tags |