package mykeynote.junit;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import junit.framework.TestCase;
import mykeynote.exceptions.configuration.ConfigurationUnacceptableValue;
import mykeynote.exceptions.configuration.MissingConfigOptionException;
import mykeynote.exceptions.configuration.UniqueFileException;
import mykeynote.exceptions.report.ReportFileCreationException;
import mykeynote.exceptions.report.ReportNotInitializedException;
import mykeynote.server.configuration.Configuration;
public class ConfigurationTest extends TestCase{
private File configuration = null;
private Configuration config = null;
public void setUp() {
configuration = new File("etc/mykeynote/MyKeyNote.conf.example");
try {
config = new Configuration(configuration, true);
config.readConfigFile();
} catch (FileNotFoundException e) {
assertNull(e);
} catch (IOException e) {
assertNull(e);
} catch (MissingConfigOptionException e) {
assertNull(e);
} catch (ReportFileCreationException e) {
assertNull(e);
} catch (ConfigurationUnacceptableValue e) {
assertNull(e);
} catch (UniqueFileException e) {
assertNull(e);
}
}
public void testConfiguration(){
assertEquals(1000, config.getMaxAllowedConnectedClients());
assertTrue("Non persistent server is per default allowed",config.getAcceptNP());
assertTrue("Debug logging is per default allowed",config.getDebugLog());
assertEquals(100, config.getMaxAllowedConnectedPC());
assertEquals(100, config.getSolingertimeout());
try {
System.out.println(config.getReport().getFileDebugLogFile().getAbsolutePath());
} catch (ReportNotInitializedException e) {
assertNull(e);
}
}
public void tearDown() {
try {
config.finalizeConfiguration();
} catch (IOException e) {
assertNull(e);
}
}
}