1 50 package org.apache.avalon.framework.configuration.test; 51 52 import java.io.File ; 53 54 import junit.framework.TestCase; 55 56 import org.apache.avalon.framework.configuration.DefaultConfiguration; 57 import org.apache.avalon.framework.configuration.DefaultConfigurationSerializer; 58 59 64 public final class DefaultConfigurationSerializerTestCase extends TestCase 65 { 66 private File testDirectory; 67 private File testDirectory2; 68 69 public DefaultConfigurationSerializerTestCase() 70 { 71 this("DefaultConfigurationSerializer Test Case "); 72 } 73 74 public DefaultConfigurationSerializerTestCase( final String name ) 75 { 76 super( name ); 77 } 78 79 public void setUp() { 80 testDirectory = (new File ("test/framework/io")).getAbsoluteFile(); 81 testDirectory2 = (new File ("test/framework/DefaultConfigurationSerializerTestCase")).getAbsoluteFile(); 82 if( !testDirectory.exists() ) 83 { 84 testDirectory.mkdirs(); 85 } 86 87 assertTrue ( !testDirectory2.exists() ); 88 } 89 90 94 public void testSerializeToFile() throws Exception 95 { 96 DefaultConfiguration config = new DefaultConfiguration("root", ""); 97 config.setAttribute( "attribute", "value" ); 98 99 File file = new File ( testDirectory, "DefaultConfigurationSerializerTestCase.xml" ); 100 101 DefaultConfigurationSerializer serializer = new DefaultConfigurationSerializer(); 102 serializer.serializeToFile( file, config ); 103 104 assertTrue( testDirectory.renameTo( testDirectory2 ) ); 108 assertTrue( testDirectory2.renameTo( testDirectory ) ); 109 110 file.delete(); 111 } 112 } 113 114 115 116 117 118 | Popular Tags |