KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > reporters > ResultAction


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/reporters/ResultAction.java,v 1.3 2004/03/30 18:08:09 sebb Exp $
2
/*
3  * Copyright 2003-2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * 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 JavaDoc;
22
23 import org.apache.jmeter.samplers.Clearable;
24 import org.apache.jmeter.samplers.SampleEvent;
25 import org.apache.jmeter.samplers.SampleListener;
26 import org.apache.jmeter.samplers.SampleResult;
27 import org.apache.jmeter.testelement.OnErrorTestElement;
28 import org.apache.jorphan.logging.LoggingManager;
29 import org.apache.log.Logger;
30
31 /**
32  * ResultAction - take action based on the status of the last Result
33  *
34  * @version $Revision: 1.3 $ Last updated: $Date: 2004/03/30 18:08:09 $
35  */

36 public class ResultAction
37     extends OnErrorTestElement
38     implements Serializable JavaDoc,
39     SampleListener,
40     Clearable
41 {
42     private static final Logger log = LoggingManager.getLoggerForClass();
43     
44     /*
45      * Constructor is initially called once for each occurrence in the test plan
46      * For GUI, several more instances are created
47      * Then clear is called at start of test
48      * Called several times during test startup
49      * The name will not necessarily have been set at this point.
50      */

51     public ResultAction(){
52         super();
53         //log.debug(Thread.currentThread().getName());
54
//System.out.println(">> "+me+" "+this.getName()+" "+Thread.currentThread().getName());
55
}
56
57     /*
58      * This is called once for each occurrence in the test plan, before the start of the test.
59      * The super.clear() method clears the name (and all other properties),
60      * so it is called last.
61      */

62     public void clear()
63     {
64         //System.out.println("-- "+me+this.getName()+" "+Thread.currentThread().getName());
65
super.clear();
66     }
67     
68     /**
69      * Examine the sample(s) and take appropriate action
70      *
71      * @see org.apache.jmeter.samplers.SampleListener#sampleOccurred(org.apache.jmeter.samplers.SampleEvent)
72      */

73     public void sampleOccurred(SampleEvent e) {
74         SampleResult s = e.getResult();
75         log.debug(s.getSampleLabel()+" OK? "+s.isSuccessful());
76         if (!s.isSuccessful()) {
77             if (isStopTest()) {
78                 s.setStopTest(true);
79             }
80             if (isStopThread()) {
81                 s.setStopThread(true);
82             }
83         }
84     }
85
86     /* (non-Javadoc)
87      * @see org.apache.jmeter.samplers.SampleListener#sampleStarted(org.apache.jmeter.samplers.SampleEvent)
88      */

89     public void sampleStarted(SampleEvent e)
90     {
91         // not used
92
}
93
94     /* (non-Javadoc)
95      * @see org.apache.jmeter.samplers.SampleListener#sampleStopped(org.apache.jmeter.samplers.SampleEvent)
96      */

97     public void sampleStopped(SampleEvent e)
98     {
99         // not used
100
}
101 }
102
Popular Tags