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.reporters;
20:
21: import java.io.Serializable;
22:
23: import org.apache.jmeter.samplers.SampleEvent;
24: import org.apache.jmeter.samplers.SampleListener;
25: import org.apache.jmeter.samplers.SampleResult;
26: import org.apache.jmeter.testelement.OnErrorTestElement;
27: import org.apache.jorphan.logging.LoggingManager;
28: import org.apache.log.Logger;
29:
30: /**
31: * ResultAction - take action based on the status of the last Result
32: *
33: */
34: public class ResultAction extends OnErrorTestElement implements
35: Serializable, SampleListener {
36: private static final Logger log = LoggingManager
37: .getLoggerForClass();
38:
39: /*
40: * Constructor is initially called once for each occurrence in the test plan
41: * For GUI, several more instances are created Then clear is called at start
42: * of test Called several times during test startup The name will not
43: * necessarily have been set at this point.
44: */
45: public ResultAction() {
46: super ();
47: // log.debug(Thread.currentThread().getName());
48: // System.out.println(">> "+me+" "+this.getName()+"
49: // "+Thread.currentThread().getName());
50: }
51:
52: /**
53: * Examine the sample(s) and take appropriate action
54: *
55: * @see org.apache.jmeter.samplers.SampleListener#sampleOccurred(org.apache.jmeter.samplers.SampleEvent)
56: */
57: public void sampleOccurred(SampleEvent e) {
58: SampleResult s = e.getResult();
59: log.debug(s.getSampleLabel() + " OK? " + s.isSuccessful());
60: if (!s.isSuccessful()) {
61: if (isStopTest()) {
62: s.setStopTest(true);
63: }
64: if (isStopThread()) {
65: s.setStopThread(true);
66: }
67: }
68: }
69:
70: /*
71: * (non-Javadoc)
72: *
73: * @see org.apache.jmeter.samplers.SampleListener#sampleStarted(org.apache.jmeter.samplers.SampleEvent)
74: */
75: public void sampleStarted(SampleEvent e) {
76: // not used
77: }
78:
79: /*
80: * (non-Javadoc)
81: *
82: * @see org.apache.jmeter.samplers.SampleListener#sampleStopped(org.apache.jmeter.samplers.SampleEvent)
83: */
84: public void sampleStopped(SampleEvent e) {
85: // not used
86: }
87:
88: }
|