View | Details | Raw Unified | Return to bug 41913
Collapse All | Expand All

(-)C:/Documents and Settings/alf.hogemark/workspace/Jmeter 2.2/src/components/org/apache/jmeter/control/gui/TransactionControllerGui.java (+54 lines)
Lines 19-28 Link Here
19
package org.apache.jmeter.control.gui;
19
package org.apache.jmeter.control.gui;
20
20
21
import java.awt.BorderLayout;
21
import java.awt.BorderLayout;
22
import java.awt.FlowLayout;
22
23
24
import javax.swing.BorderFactory;
25
import javax.swing.ButtonGroup;
26
import javax.swing.JPanel;
27
import javax.swing.JRadioButton;
28
23
import org.apache.jmeter.control.TransactionController;
29
import org.apache.jmeter.control.TransactionController;
24
import org.apache.jmeter.control.gui.AbstractControllerGui;
30
import org.apache.jmeter.control.gui.AbstractControllerGui;
31
import org.apache.jmeter.gui.util.VerticalPanel;
25
import org.apache.jmeter.testelement.TestElement;
32
import org.apache.jmeter.testelement.TestElement;
33
import org.apache.jmeter.util.JMeterUtils;
26
34
27
/**
35
/**
28
 * A Transaction controller component.
36
 * A Transaction controller component.
Lines 30-35 Link Here
30
 * @version $Revision$ on $Date$
38
 * @version $Revision$ on $Date$
31
 */
39
 */
32
public class TransactionControllerGui extends AbstractControllerGui {
40
public class TransactionControllerGui extends AbstractControllerGui {
41
    /** Radio button indicating that no samples of the trasanction should be added */
42
    private JRadioButton reportSamplesNone;
43
    /** Radio button indicating that failing samples of the trasanction should be added */
44
    private JRadioButton reportSamplesFailing;
45
    /** Radio button indicating that all samples of the trasanction should be added */
46
    private JRadioButton reportSamplesAll;
47
33
	/**
48
	/**
34
	 * Create a new TransactionControllerGui instance.
49
	 * Create a new TransactionControllerGui instance.
35
	 */
50
	 */
Lines 47-54 Link Here
47
	/* Implements JMeterGUIComponent.modifyTestElement(TestElement) */
62
	/* Implements JMeterGUIComponent.modifyTestElement(TestElement) */
48
	public void modifyTestElement(TestElement el) {
63
	public void modifyTestElement(TestElement el) {
49
		configureTestElement(el);
64
		configureTestElement(el);
65
        
66
        if (el instanceof TransactionController) {
67
            TransactionController transactionController = (TransactionController) el;
68
            transactionController.setReportSamplesNone(reportSamplesNone.isSelected());
69
            transactionController.setReportSamplesFailing(reportSamplesFailing.isSelected());
70
            transactionController.setReportSamplesAll(reportSamplesAll.isSelected());
71
        }
50
	}
72
	}
51
73
74
    public void configure(TestElement el) {
75
        super.configure(el);
76
        
77
        TransactionController transactionController = (TransactionController) el;
78
        reportSamplesNone.setSelected(transactionController.getReportSamplesNone());
79
        reportSamplesFailing.setSelected(transactionController.getReportSamplesFailing());
80
        reportSamplesAll.setSelected(transactionController.getReportSamplesAll());
81
    }
82
52
	public String getLabelResource() {
83
	public String getLabelResource() {
53
		return "transaction_controller_title";
84
		return "transaction_controller_title";
54
	}
85
	}
Lines 60-64 Link Here
60
		setLayout(new BorderLayout());
91
		setLayout(new BorderLayout());
61
		setBorder(makeBorder());
92
		setBorder(makeBorder());
62
		add(makeTitlePanel(), BorderLayout.NORTH);
93
		add(makeTitlePanel(), BorderLayout.NORTH);
94
95
        VerticalPanel mainPanel = new VerticalPanel();
96
        
97
        // Crate radiobuttons to control how samples are handled
98
        JPanel reportSamplesPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
99
        reportSamplesPanel.setBorder(
100
            BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
101
            JMeterUtils.getResString("transaction_controller_report_samples")));
102
        
103
        ButtonGroup group = new ButtonGroup();
104
        reportSamplesNone = new JRadioButton(JMeterUtils.getResString("transaction_controller_report_samples_none"));
105
        reportSamplesFailing = new JRadioButton(JMeterUtils.getResString("transaction_controller_report_samples_failing"));
106
        reportSamplesAll = new JRadioButton(JMeterUtils.getResString("transaction_controller_report_samples_all"));
107
        group.add(reportSamplesNone);
108
        group.add(reportSamplesFailing);
109
        group.add(reportSamplesAll);
110
        reportSamplesPanel.add(reportSamplesNone);
111
        reportSamplesPanel.add(reportSamplesFailing);
112
        reportSamplesPanel.add(reportSamplesAll);
113
        
114
        mainPanel.add(reportSamplesPanel);
115
        
116
        add(mainPanel, BorderLayout.CENTER);
63
	}
117
	}
64
}
118
}
(-)C:/Documents and Settings/alf.hogemark/workspace/Jmeter 2.2/src/components/org/apache/jmeter/control/TransactionController.java (-14 / +78 lines)
Lines 21-28 Link Here
21
import java.io.Serializable;
21
import java.io.Serializable;
22
22
23
import org.apache.jmeter.samplers.SampleEvent;
23
import org.apache.jmeter.samplers.SampleEvent;
24
import org.apache.jmeter.samplers.SampleListener;
24
import org.apache.jmeter.samplers.SampleResult;
25
import org.apache.jmeter.samplers.SampleResult;
25
import org.apache.jmeter.samplers.Sampler;
26
import org.apache.jmeter.samplers.Sampler;
27
import org.apache.jmeter.testelement.property.BooleanProperty;
26
import org.apache.jmeter.threads.JMeterContext;
28
import org.apache.jmeter.threads.JMeterContext;
27
import org.apache.jmeter.threads.JMeterThread;
29
import org.apache.jmeter.threads.JMeterThread;
28
import org.apache.jmeter.threads.JMeterVariables;
30
import org.apache.jmeter.threads.JMeterVariables;
Lines 35-49 Link Here
35
 * Transaction Controller to measure transaction times
37
 * Transaction Controller to measure transaction times
36
 * 
38
 * 
37
 */
39
 */
38
public class TransactionController extends GenericController implements Controller, Serializable {
40
public class TransactionController extends GenericController implements SampleListener, Controller, Serializable {
39
	protected static final Logger log = LoggingManager.getLoggerForClass();
41
	protected static final Logger log = LoggingManager.getLoggerForClass();
40
42
43
    private final static String REPORT_SAMPLES_NONE = "TransactionController.report_samples_none"; // $NON-NLS-1$
44
45
    private final static String REPORT_SAMPLES_FAILING = "TransactionController.report_samples_failing"; // $NON-NLS-1$
46
47
    private final static String REPORT_SAMPLES_ALL = "TransactionController.report_samples_all"; // $NON-NLS-1$
48
41
	transient private String threadName;
49
	transient private String threadName;
42
50
43
	transient private ListenerNotifier lnf;
51
	transient private ListenerNotifier lnf;
44
52
45
	transient private SampleResult res;
53
	transient private SampleResult res;
54
    
55
    transient private int calls;
46
56
57
    transient private int noFailingSamples;
58
47
	/**
59
	/**
48
	 * Creates a Transaction Controller
60
	 * Creates a Transaction Controller
49
	 */
61
	 */
Lines 62-87 Link Here
62
		String n = this.getName();
74
		String n = this.getName();
63
		log.debug(threadName + " " + n + " " + s);
75
		log.debug(threadName + " " + n + " " + s);
64
	}
76
	}
77
    
78
    public void setReportSamplesNone(boolean value) {
79
        setProperty(new BooleanProperty(REPORT_SAMPLES_NONE, value));
80
    }
65
81
66
	private int calls;
82
    public boolean getReportSamplesNone() {
83
        return getPropertyAsBoolean(REPORT_SAMPLES_NONE, true);
84
    }
67
85
86
    public void setReportSamplesFailing(boolean value) {
87
        setProperty(new BooleanProperty(REPORT_SAMPLES_FAILING, value));
88
    }
89
90
    public boolean getReportSamplesFailing() {
91
        return getPropertyAsBoolean(REPORT_SAMPLES_FAILING, false);
92
    }
93
94
    public void setReportSamplesAll(boolean value) {
95
        setProperty(new BooleanProperty(REPORT_SAMPLES_ALL, value));
96
    }
97
98
    public boolean getReportSamplesAll() {
99
        return getPropertyAsBoolean(REPORT_SAMPLES_ALL, false);
100
    }
101
68
	/**
102
	/**
69
	 * @see org.apache.jmeter.control.Controller#next()
103
	 * @see org.apache.jmeter.control.Controller#next()
70
	 */
104
	 */
71
	public Sampler next() {
105
	public Sampler next() {
72
		Sampler returnValue = null;
73
		if (isFirst()) // must be the start of the subtree
106
		if (isFirst()) // must be the start of the subtree
74
		{
107
		{
75
			log_debug("+++++++++++++++++++++++++++++");
108
			log_debug("+++++++++++++++++++++++++++++");
76
			calls = 0;
109
			calls = 0;
110
            noFailingSamples = 0;
77
			res = new SampleResult();
111
			res = new SampleResult();
112
            res.setSampleLabel(getName());
113
            // Assume success
114
            res.setSuccessful(true);
78
			res.sampleStart();
115
			res.sampleStart();
79
		}
116
		}
80
117
81
		calls++;
118
        Sampler returnValue = super.next();
82
119
        
83
		returnValue = super.next();
84
85
		if (returnValue == null) // Must be the end of the controller
120
		if (returnValue == null) // Must be the end of the controller
86
		{
121
		{
87
			log_debug("-----------------------------" + calls);
122
			log_debug("-----------------------------" + calls);
Lines 89-99 Link Here
89
				log_debug("already called");
124
				log_debug("already called");
90
			} else {
125
			} else {
91
				res.sampleEnd();
126
				res.sampleEnd();
92
				res.setSuccessful(true);
127
                res.setResponseMessage("Number of samples in transaction : " + calls + ", number of failing samples : " + noFailingSamples);
93
				res.setSampleLabel(getName());
128
                if(res.isSuccessful()) {
94
				res.setResponseCodeOK();
129
                    res.setResponseCodeOK();
95
				res.setResponseMessage("Called: " + calls);
130
                }
96
				res.setThreadName(threadName);
97
131
98
				// TODO could these be done earlier (or just once?)
132
				// TODO could these be done earlier (or just once?)
99
                JMeterContext threadContext = getThreadContext();
133
                JMeterContext threadContext = getThreadContext();
Lines 103-114 Link Here
103
				if (pack == null) {
137
				if (pack == null) {
104
					log.warn("Could not fetch SamplePackage");
138
					log.warn("Could not fetch SamplePackage");
105
				} else {
139
				} else {
106
					lnf.notifyListeners(new SampleEvent(res, getName()), pack.getSampleListeners());
140
                    SampleEvent event = new SampleEvent(res, getName());
141
                    // We must set res to null now, before sending the event for the transaction,
142
                    // so that we can ignore that event in our sampleOccured method 
143
                    res = null;
144
					lnf.notifyListeners(event, pack.getSampleListeners());
107
				}
145
				}
108
				res = null;
109
			}
146
			}
110
		}
147
		}
148
        else {
149
            // We have sampled one of our children
150
            calls++;            
151
        }
111
152
112
		return returnValue;
153
		return returnValue;
113
	}
154
	}
155
    
156
    public void sampleOccurred(SampleEvent se) {
157
        // Check if we have are still sampling our children
158
        if(res != null) {
159
            SampleResult sampleResult = se.getResult(); 
160
            res.setThreadName(sampleResult.getThreadName());
161
            res.setBytes(res.getBytes() + sampleResult.getBytes());
162
            if(!sampleResult.isSuccessful()) {
163
                res.setSuccessful(false);
164
                noFailingSamples++;
165
            }
166
            // Check if we should include the sample in the transaction sample
167
            if(getReportSamplesAll() || (getReportSamplesFailing() && !sampleResult.isSuccessful())) {
168
                res.addSubResult(sampleResult);
169
            }
170
        }
171
    }
172
173
    public void sampleStarted(SampleEvent e) {
174
    }
175
176
    public void sampleStopped(SampleEvent e) {
177
    }
114
}
178
}
(-)C:/Documents and Settings/alf.hogemark/workspace/Jmeter 2.2/src/core/org/apache/jmeter/resources/messages.properties (+4 lines)
Lines 732-737 Link Here
732
time_format=Format string for SimpleDateFormat (optional)
732
time_format=Format string for SimpleDateFormat (optional)
733
timelim=Time limit
733
timelim=Time limit
734
transaction_controller_title=Transaction Controller
734
transaction_controller_title=Transaction Controller
735
transaction_controller_report_samples=Samples of the transaction to include in the transaction sample
736
transaction_controller_report_samples_none=None
737
transaction_controller_report_samples_failing=Failing
738
transaction_controller_report_samples_all=All
735
unbind=Thread Unbind
739
unbind=Thread Unbind
736
uniform_timer_delay=Constant Delay Offset (in milliseconds)\:
740
uniform_timer_delay=Constant Delay Offset (in milliseconds)\:
737
uniform_timer_memo=Adds a random delay with a uniform distribution
741
uniform_timer_memo=Adds a random delay with a uniform distribution
(-)C:/Documents and Settings/alf.hogemark/workspace/Jmeter 2.2/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java (-1 / +12 lines)
Lines 200-206 Link Here
200
		addSubResults(currNode, res);
200
		addSubResults(currNode, res);
201
		// Add any assertion that failed as children of the sample node
201
		// Add any assertion that failed as children of the sample node
202
		AssertionResult assertionResults[] = res.getAssertionResults();
202
		AssertionResult assertionResults[] = res.getAssertionResults();
203
		int assertionIndex = 0;
203
		int assertionIndex = currNode.getChildCount();
204
		for (int j = 0; j < assertionResults.length; j++) {
204
		for (int j = 0; j < assertionResults.length; j++) {
205
			AssertionResult item = assertionResults[j];
205
			AssertionResult item = assertionResults[j];
206
			
206
			
Lines 231-236 Link Here
231
231
232
			treeModel.insertNodeInto(leafNode, currNode, leafIndex++);
232
			treeModel.insertNodeInto(leafNode, currNode, leafIndex++);
233
			addSubResults(leafNode, child);
233
			addSubResults(leafNode, child);
234
            // Add any assertion that failed as children of the sample node
235
            AssertionResult assertionResults[] = child.getAssertionResults();
236
            int assertionIndex = leafNode.getChildCount();
237
            for (int j = 0; j < assertionResults.length; j++) {
238
                AssertionResult item = assertionResults[j];
239
                
240
                if (item.isFailure() || item.isError()) {
241
                    DefaultMutableTreeNode assertionNode = new DefaultMutableTreeNode(item);
242
                    treeModel.insertNodeInto(assertionNode, leafNode, assertionIndex++);
243
                }
244
            }
234
		}
245
		}
235
	}
246
	}
236
247

Return to bug 41913