001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: package org.apache.jmeter.testelement;
020:
021: import org.apache.jmeter.testelement.property.JMeterProperty;
022: import org.apache.jmeter.testelement.property.PropertyIterator;
023: import org.apache.jmeter.threads.JMeterContext;
024:
025: public interface TestElement extends Cloneable {
026: public final static String NAME = "TestElement.name"; //$NON-NLS-1$
027:
028: public final static String GUI_CLASS = "TestElement.gui_class"; //$NON-NLS-1$
029:
030: public final static String ENABLED = "TestElement.enabled"; //$NON-NLS-1$
031:
032: public final static String TEST_CLASS = "TestElement.test_class"; //$NON-NLS-1$
033:
034: // Needed by AbstractTestElement.
035: // Also TestElementConverter and TestElementPropertyConverter for handling empty comments
036: public final static String COMMENTS = "TestPlan.comments"; //$NON-NLS-1$
037:
038: // N.B. Comments originally only applied to Test Plans, hence the name - which can now not be easily changed
039:
040: public void addTestElement(TestElement child);
041:
042: public void setProperty(String key, String value);
043:
044: public void setProperty(String key, boolean value);
045:
046: /**
047: * Check if ENABLED property is present and true ; defaults to true
048: *
049: * @return true if element is enabled
050: */
051: public boolean isEnabled();
052:
053: /**
054: * Returns true or false whether the element is the running version.
055: */
056: public boolean isRunningVersion();
057:
058: /**
059: * Test whether a given property is only a temporary resident of the
060: * TestElement
061: *
062: * @param property
063: * @return boolean
064: */
065: public boolean isTemporary(JMeterProperty property);
066:
067: /**
068: * Indicate that the given property should be only a temporary property in
069: * the TestElement
070: *
071: * @param property
072: * void
073: */
074: public void setTemporary(JMeterProperty property);
075:
076: /**
077: * Return a property as a boolean value.
078: */
079: public boolean getPropertyAsBoolean(String key);
080:
081: public boolean getPropertyAsBoolean(String key, boolean defaultValue);
082:
083: public long getPropertyAsLong(String key);
084:
085: public int getPropertyAsInt(String key);
086:
087: public float getPropertyAsFloat(String key);
088:
089: public double getPropertyAsDouble(String key);
090:
091: /**
092: * Make the test element the running version, or make it no longer the
093: * running version. This tells the test element that it's current state must
094: * be retrievable by a call to recoverRunningVersion(). It is kind of like
095: * making the TestElement Read- Only, but not as strict. Changes can be made
096: * and the element can be modified, but the state of the element at the time
097: * of the call to setRunningVersion() must be recoverable.
098: */
099: public void setRunningVersion(boolean run);
100:
101: /**
102: * Tells the test element to return to the state it was in when
103: * makeRunningVersion() was called.
104: */
105: public void recoverRunningVersion();
106:
107: /**
108: * Clear the TestElement of all data.
109: */
110: public void clear();
111:
112: // TODO - yet another ambiguous name - does it need changing?
113: // See also: Clearable, JMeterGUIComponent
114:
115: public String getPropertyAsString(String key);
116:
117: public String getPropertyAsString(String key, String defaultValue);
118:
119: /**
120: * Sets and overwrites a property in the TestElement. This call will be
121: * ignored if the TestElement is currently a "running version".
122: */
123: public void setProperty(JMeterProperty property);
124:
125: /**
126: * Given the name of the property, returns the appropriate property from
127: * JMeter. If it is null, a NullProperty object will be returned.
128: */
129: public JMeterProperty getProperty(String propName);
130:
131: /**
132: * Get a Property Iterator for the TestElements properties.
133: *
134: * @return PropertyIterator
135: */
136: public PropertyIterator propertyIterator();
137:
138: public void removeProperty(String key);
139:
140: // lifecycle methods
141:
142: public Object clone();
143:
144: /**
145: * Convenient way to traverse a test element.
146: */
147: public void traverse(TestElementTraverser traverser);
148:
149: /**
150: * @return Returns the threadContext.
151: */
152: public JMeterContext getThreadContext();
153:
154: /**
155: * @param threadContext
156: * The threadContext to set.
157: */
158: public void setThreadContext(JMeterContext threadContext);
159:
160: /**
161: * @return Returns the threadName.
162: */
163: public String getThreadName();
164:
165: /**
166: * @param threadName
167: * The threadName to set.
168: */
169: public void setThreadName(String threadName);
170:
171: /**
172: * Called by Remove to determine if it is safe to remove the element. The
173: * element can either clean itself up, and return true, or the element can
174: * return false.
175: *
176: * @return true if safe to remove the element
177: */
178: public boolean canRemove();
179:
180: public String getName();
181:
182: public void setName(String name);
183:
184: public String getComment();
185:
186: public void setComment(String comment);
187: }
|