1 17 18 package org.apache.avalon.logging.data.test; 19 20 import org.apache.avalon.logging.data.CategoryDirective; 21 import org.apache.avalon.logging.data.CategoriesDirective; 22 23 import java.io.*; 24 25 31 public class CategoriesDirectiveTestCase extends CategoryDirectiveTestCase 32 { 33 public CategoriesDirectiveTestCase( String name ) 34 { 35 super( name ); 36 } 37 38 public void testCategories() 39 { 40 String catName = "name"; 41 CategoriesDirective cat = 42 new CategoriesDirective( 43 catName, null, null, new CategoryDirective[0] ); 44 testCategory( cat, catName, null, null ); 45 } 46 47 public void testSerialization() throws IOException, ClassNotFoundException 48 { 49 File file = new File("name.test"); 50 String name = "name"; 51 String priority = CategoryDirective.WARN; 52 String target = "test"; 53 54 CategoriesDirective original = 55 new CategoriesDirective( name, priority, target, new CategoryDirective[0] ); 56 57 testCategory( original, name, priority, target ); 58 59 ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file)); 60 oos.writeObject(original); 61 oos.close(); 62 63 ObjectInputStream ois = new ObjectInputStream( new FileInputStream(file)); 64 CategoriesDirective serialized = (CategoriesDirective)ois.readObject(); 65 ois.close(); 66 67 file.delete(); 68 69 testCategory( serialized, name, priority, target ); 70 71 assertEquals( original, serialized ); 72 assertEquals( original.hashCode(), serialized.hashCode() ); 73 } 74 } 75 | Popular Tags |