01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: /*
20: * Created on Apr 30, 2003
21: *
22: * To change the template for this generated file go to
23: * Window>Preferences>Java>Code Generation>Code and Comments
24: */
25: package org.apache.jmeter.junit.stubs;
26:
27: import org.apache.jmeter.samplers.AbstractSampler;
28: import org.apache.jmeter.samplers.Entry;
29: import org.apache.jmeter.samplers.SampleResult;
30:
31: /**
32: * @author ano ano
33: *
34: * To change the template for this generated type comment go to
35: * Window>Preferences>Java>Code Generation>Code and Comments
36: */
37: public class TestSampler extends AbstractSampler {
38:
39: private long wait = 0;
40:
41: private long samples = 0; // number of samples taken
42:
43: /*
44: * (non-Javadoc)
45: *
46: * @see org.apache.jmeter.samplers.Sampler#sample(org.apache.jmeter.samplers.Entry)
47: */
48: public SampleResult sample(Entry e) {
49: if (wait > 0) {
50: try {
51: Thread.sleep(wait);
52: } catch (InterruptedException e1) {
53: // ignore
54: }
55: }
56: samples++;
57: return null;
58: }
59:
60: public TestSampler(String name, long wait) {
61: setName(name);
62: this .wait = wait;
63: }
64:
65: public TestSampler(String name) {
66: setName(name);
67: }
68:
69: public TestSampler() {
70: }
71:
72: public String toString() {
73: return getName();
74: }
75:
76: public long getSamples() {
77: return samples;
78: }
79: }
|