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.threads;
020:
021: import java.util.Iterator;
022: import java.util.LinkedList;
023: import java.util.List;
024:
025: import org.apache.jmeter.assertions.Assertion;
026: import org.apache.jmeter.processor.PostProcessor;
027: import org.apache.jmeter.processor.PreProcessor;
028: import org.apache.jmeter.samplers.SampleListener;
029: import org.apache.jmeter.samplers.Sampler;
030: import org.apache.jmeter.testelement.TestElement;
031: import org.apache.jmeter.timers.Timer;
032: import org.apache.jorphan.logging.LoggingManager;
033: import org.apache.log.Logger;
034:
035: /**
036: * @author Michael Stover
037: * @version $Revision: 493779 $
038: */
039: public class SamplePackage {
040: private static Logger log = LoggingManager.getLoggerForClass();
041:
042: List sampleListeners = new LinkedList();
043:
044: List timers = new LinkedList();
045:
046: List assertions = new LinkedList();
047:
048: List postProcessors = new LinkedList();
049:
050: List preProcessors = new LinkedList();
051:
052: List responseModifiers;
053:
054: List configs;
055:
056: List modifiers;
057:
058: List controllers;
059:
060: Sampler sampler;
061:
062: public SamplePackage() {
063: }
064:
065: public SamplePackage(List configs, List modifiers,
066: List responseModifiers, List listeners, List timers,
067: List assertions, List extractors, List pres,
068: List controllers) {
069: log.debug("configs is null: " + (configs == null));
070: this .configs = configs;
071: this .modifiers = modifiers;
072: this .responseModifiers = responseModifiers;
073: this .sampleListeners = listeners;
074: this .timers = timers;
075: this .assertions = assertions;
076: this .postProcessors = extractors;
077: this .preProcessors = pres;
078: this .controllers = controllers;
079: }
080:
081: public void setRunningVersion(boolean running) {
082: setRunningVersion(configs, running);
083: setRunningVersion(modifiers, running);
084: setRunningVersion(sampleListeners, running);
085: setRunningVersion(assertions, running);
086: setRunningVersion(timers, running);
087: setRunningVersion(responseModifiers, running);
088: setRunningVersion(postProcessors, running);
089: setRunningVersion(preProcessors, running);
090: setRunningVersion(controllers, running);
091: sampler.setRunningVersion(running);
092: }
093:
094: private void setRunningVersion(List list, boolean running) {
095: Iterator iter = list.iterator();
096: while (iter.hasNext()) {
097: ((TestElement) iter.next()).setRunningVersion(running);
098: }
099: }
100:
101: private void recoverRunningVersion(List list) {
102: Iterator iter = list.iterator();
103: while (iter.hasNext()) {
104: ((TestElement) iter.next()).recoverRunningVersion();
105: }
106: }
107:
108: public void recoverRunningVersion() {
109: recoverRunningVersion(configs);
110: recoverRunningVersion(modifiers);
111: recoverRunningVersion(sampleListeners);
112: recoverRunningVersion(assertions);
113: recoverRunningVersion(timers);
114: recoverRunningVersion(responseModifiers);
115: recoverRunningVersion(postProcessors);
116: recoverRunningVersion(preProcessors);
117: recoverRunningVersion(controllers);
118: sampler.recoverRunningVersion();
119: }
120:
121: public List getSampleListeners() {
122: return sampleListeners;
123: }
124:
125: public void addSampleListener(SampleListener listener) {
126: sampleListeners.add(listener);
127: }
128:
129: public List getTimers() {
130: return timers;
131: }
132:
133: public void addPostProcessor(PostProcessor ex) {
134: postProcessors.add(ex);
135: }
136:
137: public void addPreProcessor(PreProcessor pre) {
138: preProcessors.add(pre);
139: }
140:
141: public void addTimer(Timer timer) {
142: timers.add(timer);
143: }
144:
145: public void addAssertion(Assertion asser) {
146: assertions.add(asser);
147: }
148:
149: public List getAssertions() {
150: return assertions;
151: }
152:
153: public List getPostProcessors() {
154: return postProcessors;
155: }
156:
157: public Sampler getSampler() {
158: return sampler;
159: }
160:
161: public void setSampler(Sampler s) {
162: sampler = s;
163: }
164:
165: /**
166: * Returns the preProcessors.
167: */
168: public List getPreProcessors() {
169: return preProcessors;
170: }
171:
172: /**
173: * Sets the preProcessors.
174: *
175: * @param preProcessors
176: * the preProcessors to set
177: */
178: public void setPreProcessors(List preProcessors) {
179: this .preProcessors = preProcessors;
180: }
181:
182: /**
183: * Returns the configs.
184: *
185: * @return List
186: */
187: public List getConfigs() {
188: return configs;
189: }
190:
191: /**
192: * Returns the modifiers.
193: */
194: public List getModifiers() {
195: return modifiers;
196: }
197:
198: /**
199: * Returns the responseModifiers.
200: */
201: public List getResponseModifiers() {
202: return responseModifiers;
203: }
204:
205: /**
206: * Sets the assertions.
207: *
208: * @param assertions
209: * the assertions to set
210: */
211: public void setAssertions(List assertions) {
212: this .assertions = assertions;
213: }
214:
215: /**
216: * Sets the configs.
217: *
218: * @param configs
219: * the configs to set
220: */
221: public void setConfigs(List configs) {
222: this .configs = configs;
223: }
224:
225: /**
226: * Sets the modifiers.
227: *
228: * @param modifiers
229: * the modifiers to set
230: */
231: public void setModifiers(List modifiers) {
232: this .modifiers = modifiers;
233: }
234:
235: /**
236: * Sets the postProcessors.
237: *
238: * @param postProcessors
239: * the postProcessors to set
240: */
241: public void setPostProcessors(List postProcessors) {
242: this .postProcessors = postProcessors;
243: }
244:
245: /**
246: * Sets the responseModifiers.
247: *
248: * @param responseModifiers
249: * the responseModifiers to set
250: */
251: public void setResponseModifiers(List responseModifiers) {
252: this .responseModifiers = responseModifiers;
253: }
254:
255: /**
256: * Sets the sampleListeners.
257: *
258: * @param sampleListeners
259: * the sampleListeners to set
260: */
261: public void setSampleListeners(List sampleListeners) {
262: this .sampleListeners = sampleListeners;
263: }
264:
265: /**
266: * Sets the timers.
267: *
268: * @param timers
269: * the timers to set
270: */
271: public void setTimers(List timers) {
272: this.timers = timers;
273: }
274: }
|