Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/acs/damsel/srvr/TestConfig.java


1   package org.acs.damsel.srvr;
2   
3   import junit.framework.*;
4   import java.io.*;
5   
6   public class TestConfig extends TestCase {
7     private Config config = null;
8   
9     public TestConfig(String name) {
10      super(name);
11    }
12  
13    protected void setUp() throws Exception {
14      super.setUp();
15      config = null;
16    }
17  
18    protected void tearDown() throws Exception {
19      config = null;
20      super.tearDown();
21    }
22  
23    /*
24     * Test saving and loading the Config object to and from an XML file.
25     */
26    public void testSaveAndLoad() {
27      config = config.instance();
28      config.setPrefix("C:/Documents and Settings/ACS/jbproject/damsel/");
29      config.setConfigFileName("testconfig.xml");
30      File f = new File(Config.instance().getPrefix() + "testconfig.xml");
31      try {
32        config.save(f);
33      }
34      catch (IOException ex) {
35        this.fail("Caught unexpected IOException while saving config.");
36      }
37      config.invalidate();
38      // note that instance will automatically attempt to load the saved file
39      config = config.instance(f);
40      this.assertEquals("testconfig.xml", config.getConfigFileName());
41      f.delete();
42    }
43  
44    /*
45     * Saves the Config object.  Leave commented out unless you want to make a
46     * new saved file.
47     */
48    /*public void testSave() {
49      config = config.instance();
50      config.invalidate();
51      config = config.instance();
52      File f= new File(config.getPrefix() + "config.xml");
53      try {
54        config.save(f);
55      }
56      catch (IOException ex) {
57        this.fail("Caught unexpected IOException while saving config.");
58      }
59    }*/
60  }