KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > cruisecontrol > ProjectStateTest


1 /*
2  * Created on Apr 8, 2005
3  */

4 package net.sourceforge.cruisecontrol;
5
6 import java.io.File JavaDoc;
7 import java.io.FileInputStream JavaDoc;
8 import java.io.FileOutputStream JavaDoc;
9 import java.io.ObjectInputStream JavaDoc;
10 import java.io.ObjectOutputStream JavaDoc;
11
12 import junit.framework.TestCase;
13
14 /**
15  * @author Jeffrey Fredrick
16  */

17 public class ProjectStateTest extends TestCase {
18
19     private static final String JavaDoc QUEUED_OBJECT_FILE = "target/queued.object";
20     
21     protected void tearDown() throws Exception JavaDoc {
22         File JavaDoc file = new File JavaDoc(QUEUED_OBJECT_FILE);
23         if (file.exists()) {
24             file.delete();
25         }
26     }
27
28     public void testSerialization() throws Exception JavaDoc {
29         FileOutputStream JavaDoc fos = new FileOutputStream JavaDoc(QUEUED_OBJECT_FILE);
30         ObjectOutputStream JavaDoc oos = new ObjectOutputStream JavaDoc(fos);
31         oos.writeObject(ProjectState.QUEUED);
32         oos.close();
33
34         FileInputStream JavaDoc fis = new FileInputStream JavaDoc(QUEUED_OBJECT_FILE);
35         ObjectInputStream JavaDoc ois = new ObjectInputStream JavaDoc(fis);
36         ProjectState queued = (ProjectState) ois.readObject();
37         ois.close();
38
39         assertTrue(ProjectState.QUEUED == queued);
40     }
41
42 }
Popular Tags