/*
* Copyright 2009 Peter Karich, peat_hal 'at' users 'dot' sourceforge 'dot' net.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* under the License.
*/
package de.timefinder.core.io.xml;
import java.io.File;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* @author Peter Karich, peat_hal 'at' users 'dot' sourceforge 'dot' net
*/
public class XmlSettingsTest {
private XmlSettings settings;
public XmlSettingsTest() {
}
@Before
public void setUp() {
}
@Test
public void testLoad() throws Exception {
File file = new File("src/test/settings.xml");
file.deleteOnExit();
settings = new XmlSettings();
settings.setSettingsFile(file);
settings.setObject("test", "this is me");
settings.setObject("bool", true);
settings.setObject("file", new File("test.xml"));
settings.setObject("myclass", XmlSettings.class);
settings.save();
settings = new XmlSettings();
settings.setSettingsFile(file);
settings.load();
assertEquals("this is me", settings.getObject("test"));
assertEquals(true, settings.getObject("bool"));
assertEquals("test.xml", ((File) settings.getObject("file")).getName());
assertEquals(XmlSettings.class, ((Class) settings.getObject("myclass")));
}
}