View Javadoc
1 /* 2 * Copyright (c) 2001 by 3 * Siegfried GOESCHL <mailto:siegfried.goeschl@itserv.at>; 4 * and Dima STADNIK <mailto:5d5@mail.ru>; 5 * 6 * This program is free software. 7 * 8 * You may redistribute it and/or modify it under the terms of the GNU 9 * General Public License as published by the Free Software Foundation. 10 * Version 2 of the license should be included with this distribution in 11 * the file LICENSE, as well as License.html. If the license is not 12 * included with this distribution, you may find a copy at the FSF web 13 * site at 'www.gnu.org' or 'www.fsf.org', or you may write to the 14 * Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139 USA. 15 * 16 * THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND, 17 * NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR 18 * OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY 19 * CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR 20 * REDISTRIBUTION OF THIS SOFTWARE. 21 */ 22 23 package junit.extensions; 24 25 import junit.framework.TestCase; 26 import junit.extensions.conf.Configuration; 27 import junit.extensions.conf.ConfigurationFactory; 28 29 /*** 30 * Base class for test cases which are configured using a configuration file 31 * instead of hardcoding test data in the fixture. 32 * 33 * @author Siegfried GOESCHL 34 * @author Dima STADNIK 35 */ 36 public class ConfigurableTestCase extends TestCase implements ConfigurableTest { 37 38 /*** Cached configuration. */ 39 protected Configuration conf; 40 41 /*** 42 * Creates instance of configurable test case. 43 * 44 * @param name Name of this test case. 45 */ 46 public ConfigurableTestCase(String name) { 47 super(name); 48 ConfigurationFactory.init(this.getClass()); 49 } 50 51 /*** 52 * Retrieves configuration of this test case. 53 * 54 * @return Configuration of this test case. 55 */ 56 protected Configuration getConfiguration() { 57 if (conf == null) { 58 conf = ConfigurationFactory.getFactory().getConfiguration(); 59 } 60 return conf; 61 } 62 63 // ConfigurableTest implementation //////////////////////////// 64 65 public boolean getBoolean(String key) throws IllegalArgumentException { 66 return getConfiguration().getBoolean(this, getName(), key); 67 } 68 69 public byte getByte(String key) throws IllegalArgumentException { 70 return getConfiguration().getByte(this, getName(), key); 71 } 72 73 public char getChar(String key) throws IllegalArgumentException { 74 return getConfiguration().getChar(this, getName(), key); 75 } 76 77 public double getDouble(String key) throws IllegalArgumentException { 78 return getConfiguration().getDouble(this, getName(), key); 79 } 80 81 public float getFloat(String key) throws IllegalArgumentException { 82 return getConfiguration().getFloat(this, getName(), key); 83 } 84 85 public int getInteger(String key) throws IllegalArgumentException { 86 return getConfiguration().getInteger(this, getName(), key); 87 } 88 89 public long getLong(String key) throws IllegalArgumentException { 90 return getConfiguration().getLong(this, getName(), key); 91 } 92 93 public short getShort(String key) throws IllegalArgumentException { 94 return getConfiguration().getShort(this, getName(), key); 95 } 96 97 public String getString(String key) throws IllegalArgumentException { 98 return getConfiguration().getString(this, getName(), key); 99 } 100 101 public String[] getStrings(String key) throws IllegalArgumentException { 102 return getConfiguration().getStrings(this, getName(), key); 103 } 104 }

This page was automatically generated by Maven