1 18 19 package org.apache.jmeter.threads; 20 21 import java.util.Iterator ; 22 import java.util.LinkedList ; 23 import java.util.List ; 24 25 import org.apache.jmeter.assertions.Assertion; 26 import org.apache.jmeter.processor.PostProcessor; 27 import org.apache.jmeter.processor.PreProcessor; 28 import org.apache.jmeter.samplers.SampleListener; 29 import org.apache.jmeter.samplers.Sampler; 30 import org.apache.jmeter.testelement.TestElement; 31 import org.apache.jmeter.timers.Timer; 32 import org.apache.jorphan.logging.LoggingManager; 33 import org.apache.log.Logger; 34 35 39 public class SamplePackage 40 { 41 private static Logger log = LoggingManager.getLoggerForClass(); 42 List sampleListeners = new LinkedList (); 43 List timers = new LinkedList (); 44 List assertions = new LinkedList (); 45 List postProcessors = new LinkedList (); 46 List preProcessors = new LinkedList (); 47 List responseModifiers; 48 List configs; 49 List modifiers; 50 Sampler sampler; 51 52 public SamplePackage() 53 { 54 } 55 56 public SamplePackage( 57 List configs, 58 List modifiers, 59 List responseModifiers, 60 List listeners, 61 List timers, 62 List assertions, 63 List extractors, 64 List pres) 65 { 66 log.debug("configs is null: " + (configs == null)); 67 this.configs = configs; 68 this.modifiers = modifiers; 69 this.responseModifiers = responseModifiers; 70 this.sampleListeners = listeners; 71 this.timers = timers; 72 this.assertions = assertions; 73 this.postProcessors = extractors; 74 this.preProcessors = pres; 75 } 76 77 public void setRunningVersion(boolean running) 78 { 79 setRunningVersion(configs, running); 80 setRunningVersion(modifiers, running); 81 setRunningVersion(sampleListeners, running); 82 setRunningVersion(assertions, running); 83 setRunningVersion(timers, running); 84 setRunningVersion(responseModifiers, running); 85 setRunningVersion(postProcessors, running); 86 setRunningVersion(preProcessors, running); 87 sampler.setRunningVersion(running); 88 } 89 90 private void setRunningVersion(List list,boolean running) 91 { 92 Iterator iter = list.iterator(); 93 while (iter.hasNext()) 94 { 95 ((TestElement) iter.next()).setRunningVersion(running); 96 } 97 } 98 99 private void recoverRunningVersion(List list) 100 { 101 Iterator iter = list.iterator(); 102 while (iter.hasNext()) 103 { 104 ((TestElement) iter.next()).recoverRunningVersion(); 105 } 106 } 107 108 public void recoverRunningVersion() 109 { 110 recoverRunningVersion(configs); 111 recoverRunningVersion(modifiers); 112 recoverRunningVersion(sampleListeners); 113 recoverRunningVersion(assertions); 114 recoverRunningVersion(timers); 115 recoverRunningVersion(responseModifiers); 116 recoverRunningVersion(postProcessors); 117 recoverRunningVersion(preProcessors); 118 sampler.recoverRunningVersion(); 119 } 120 121 public List getSampleListeners() 122 { 123 return sampleListeners; 124 } 125 126 public void addSampleListener(SampleListener listener) 127 { 128 sampleListeners.add(listener); 129 } 130 131 public List getTimers() 132 { 133 return timers; 134 } 135 136 public void addPostProcessor(PostProcessor ex) 137 { 138 postProcessors.add(ex); 139 } 140 141 public void addPreProcessor(PreProcessor pre) 142 { 143 preProcessors.add(pre); 144 } 145 146 public void addTimer(Timer timer) 147 { 148 timers.add(timer); 149 } 150 151 public void addAssertion(Assertion asser) 152 { 153 assertions.add(asser); 154 } 155 156 public List getAssertions() 157 { 158 return assertions; 159 } 160 161 public List getPostProcessors() 162 { 163 return postProcessors; 164 } 165 166 public Sampler getSampler() 167 { 168 return sampler; 169 } 170 171 public void setSampler(Sampler s) 172 { 173 sampler = s; 174 } 175 176 179 public List getPreProcessors() 180 { 181 return preProcessors; 182 } 183 184 188 public void setPreProcessors(List preProcessors) 189 { 190 this.preProcessors = preProcessors; 191 } 192 193 197 public List getConfigs() 198 { 199 return configs; 200 } 201 202 205 public List getModifiers() 206 { 207 return modifiers; 208 } 209 210 213 public List getResponseModifiers() 214 { 215 return responseModifiers; 216 } 217 218 222 public void setAssertions(List assertions) 223 { 224 this.assertions = assertions; 225 } 226 227 231 public void setConfigs(List configs) 232 { 233 this.configs = configs; 234 } 235 236 240 public void setModifiers(List modifiers) 241 { 242 this.modifiers = modifiers; 243 } 244 245 249 public void setPostProcessors(List postProcessors) 250 { 251 this.postProcessors = postProcessors; 252 } 253 254 258 public void setResponseModifiers(List responseModifiers) 259 { 260 this.responseModifiers = responseModifiers; 261 } 262 263 267 public void setSampleListeners(List sampleListeners) 268 { 269 this.sampleListeners = sampleListeners; 270 } 271 272 276 public void setTimers(List timers) 277 { 278 this.timers = timers; 279 } 280 } | Popular Tags |