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: package org.apache.jmeter.examples.testbeans.example2;
20:
21: import org.apache.jmeter.samplers.AbstractSampler;
22: import org.apache.jmeter.samplers.Entry;
23: import org.apache.jmeter.samplers.SampleResult;
24: import org.apache.jmeter.testbeans.TestBean;
25:
26: /**
27: * This TestBean is just an example about how to write testbeans. The intent is
28: * to demonstrate usage of the TestBean features to podential TestBean
29: * developers. Note that only the class's introspector view matters: the methods
30: * do nothing -- nothing useful, in any case.
31: */
32: public class Example2 extends AbstractSampler implements TestBean {
33:
34: public SampleResult sample(Entry e) {
35: SampleResult res = new SampleResult();
36: res.setSampleLabel(getName());
37: res.setSamplerData(myStringProperty);
38: res.sampleStart();
39: // Do something ...
40: res.setResponseData(myStringProperty.toLowerCase().getBytes());
41: res.setDataType(SampleResult.TEXT);
42: res.sampleEnd();
43: res.setSuccessful(true);
44: return res;
45: }
46:
47: private String myStringProperty;
48:
49: // A TestBean is a Java Bean. Just define some properties and they will
50: // automagically show up in the GUI.
51: // A String property:
52: public void setMyStringProperty(String s) {
53: myStringProperty = s;
54: };
55:
56: public String getMyStringProperty() {
57: return myStringProperty;
58: }
59: }
|