1 /** 2 * 3 */ 4 package net.obsearch.index.utils; 5 6 import java.io.File; 7 import java.io.IOException; 8 import java.io.InputStream; 9 import java.util.Properties; 10 11 import org.apache.log4j.PropertyConfigurator; 12 13 /* 14 OBSearch: a distributed similarity search engine 15 This project is to similarity search what 'bit-torrent' is to downloads. 16 Copyright (C) 2007 Arnoldo Jose Muller Molina 17 18 This program is free software: you can redistribute it and/or modify 19 it under the terms of the GNU General Public License as published by 20 the Free Software Foundation, either version 3 of the License, or 21 (at your option) any later version. 22 23 This program is distributed in the hope that it will be useful, 24 but WITHOUT ANY WARRANTY; without even the implied warranty of 25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 GNU General Public License for more details. 27 28 You should have received a copy of the GNU General Public License 29 along with this program. If not, see <http://www.gnu.org/licenses/>. 30 */ 31 /** 32 * Test utilities. 33 * @author Arnoldo Jose Muller Molina 34 * @since 0.7 35 */ 36 public class TUtils { 37 38 /** 39 * Properties loaded from the properties file. 40 */ 41 private static Properties testProperties = null; 42 43 /** 44 * Return the properties from the test properties file. 45 * @return the properties from the test properties file 46 * @throws IOException If the file cannot be read. 47 */ 48 public static Properties getTestProperties() throws IOException { 49 if (testProperties == null) { // load the properties only once 50 InputStream is = TUtils.class 51 .getResourceAsStream(File.separator + "test.properties"); 52 testProperties = new Properties(); 53 testProperties.load(is); 54 // configure log4j only once too 55 PropertyConfigurator.configure(testProperties 56 .getProperty("test.log4j.file")); 57 } 58 59 return testProperties; 60 } 61 62 63 64 65 }