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
26 import junit.framework.Test;
27 import junit.extensions.conf.Configuration;
28 import junit.extensions.conf.ConfigurationFactory;
29
30
31 /***
32 * A Decorator to set up and tear down additional fixture state using configuration.
33 *
34 * @author Siegfried GOESCHL
35 * @author Dima STADNIK
36 */
37 public class ConfigurableTestSetup extends TestSetup implements ConfigurableTest {
38
39 /*** Cached configuration. */
40 private Configuration conf;
41
42 /***
43 * Creates test setup instance.
44 *
45 * @param test Test for which this setup is created.
46 */
47 public ConfigurableTestSetup(Test test) {
48 super(test);
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, null, key);
67 }
68
69 public byte getByte(String key) throws IllegalArgumentException {
70 return getConfiguration().getByte(this, null, key);
71 }
72
73 public char getChar(String key) throws IllegalArgumentException {
74 return getConfiguration().getChar(this, null, key);
75 }
76
77 public double getDouble(String key) throws IllegalArgumentException {
78 return getConfiguration().getDouble(this, null, key);
79 }
80
81 public float getFloat(String key) throws IllegalArgumentException {
82 return getConfiguration().getFloat(this, null, key);
83 }
84
85 public int getInteger(String key) throws IllegalArgumentException {
86 return getConfiguration().getInteger(this, null, key);
87 }
88
89 public long getLong(String key) throws IllegalArgumentException {
90 return getConfiguration().getLong(this, null, key);
91 }
92
93 public short getShort(String key) throws IllegalArgumentException {
94 return getConfiguration().getShort(this, null, key);
95 }
96
97 public String getString(String key) throws IllegalArgumentException {
98 return getConfiguration().getString(this, null, key);
99 }
100
101 public String[] getStrings(String key) throws IllegalArgumentException {
102 return getConfiguration().getStrings(this, null, key);
103 }
104 }
This page was automatically generated by Maven