From 3b926360ef721b313ca0de6934930792c9ea5269 Mon Sep 17 00:00:00 2001 From: Robert Greene Date: Sun, 11 Jul 2004 15:10:27 +0000 Subject: [PATCH] Made TestConfig to support different desktops instead of hard-coding paths. --- .../applecommander/testconfig/TestConfig.java | 77 +++++++++++++++++++ .../testconfig/TestConfig.properties | 2 + 2 files changed, 79 insertions(+) create mode 100644 test/com/webcodepro/applecommander/testconfig/TestConfig.java create mode 100644 test/com/webcodepro/applecommander/testconfig/TestConfig.properties diff --git a/test/com/webcodepro/applecommander/testconfig/TestConfig.java b/test/com/webcodepro/applecommander/testconfig/TestConfig.java new file mode 100644 index 0000000..b421946 --- /dev/null +++ b/test/com/webcodepro/applecommander/testconfig/TestConfig.java @@ -0,0 +1,77 @@ +/* + * AppleCommander - An Apple ][ image utility. + * Copyright (C) 2002-2004 by Robert Greene + * robgreene at users.sourceforge.net + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.webcodepro.applecommander.testconfig; + +import java.io.FileInputStream; +import java.util.Properties; + +/** + * A simple class to contains test configuration information. + * Update the file TestConfig.properties to match the system. + * + * @author Rob + */ +public class TestConfig { + private static final String FILENAME = "TestConfig.preferences"; //$NON-NLS-1$ + private static final String DISK_DIRECTORY = "DiskDir"; //$NON-NLS-1$ + private static final String TEMP_DIRECTORY = "TempDir"; //$NON-NLS-1$ + private static TestConfig instance; + private Properties properties = new Properties(); + /** + * Hide constructor from other classes. + */ + private TestConfig() { + // empty + } + /** + * Get the singleton TestConfig. + */ + public static TestConfig getInstance() { + if (instance == null) { + instance = new TestConfig(); + instance.load(); + } + return instance; + } + /** + * Initialize the test config from disk. + */ + private void load() { + try { + FileInputStream inputStream = new FileInputStream(FILENAME); + properties.load(inputStream); + inputStream.close(); + } catch (Exception ignored) { + // Ignored + } + } + /** + * Answer with the temp directory. + */ + public String getTempDir() { + return properties.getProperty(TEMP_DIRECTORY); + } + /** + * Answer with the directory where disk images are stored. + */ + public String getDiskDir() { + return properties.getProperty(DISK_DIRECTORY); + } +} diff --git a/test/com/webcodepro/applecommander/testconfig/TestConfig.properties b/test/com/webcodepro/applecommander/testconfig/TestConfig.properties new file mode 100644 index 0000000..fcda40d --- /dev/null +++ b/test/com/webcodepro/applecommander/testconfig/TestConfig.properties @@ -0,0 +1,2 @@ +DiskDir=C:/Documents and Settings/Rob/My Documents/My Apple2/Disks +TempDir=C:/Temp