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

(-)src/components/Test.java (+4 lines)
Line 0 Link Here
1
2
public class Test {
3
4
}
(-)src/core/org/apache/jmeter/report/processor/ErrorsSummaryConsumer.java (-2 / +11 lines)
Lines 78-88 Link Here
78
     */
78
     */
79
    @Override
79
    @Override
80
    protected String getKeyFromSample(Sample sample) {
80
    protected String getKeyFromSample(Sample sample) {
81
        return getErrorKey(sample);
82
    }
83
84
    /**
85
     * @param sample {@link Sample}
86
     * @return Error key for sample 
87
     */
88
    static String getErrorKey(Sample sample) {
81
        String responseCode = sample.getResponseCode();
89
        String responseCode = sample.getResponseCode();
82
        String responseMessage = sample.getResponseMessage();
90
        String responseMessage = sample.getResponseMessage();
83
        String key = responseCode + (!StringUtils.isEmpty(responseMessage) ? 
91
        String key = responseCode + (!StringUtils.isEmpty(responseMessage) ? 
84
                 "/" + StringEscapeUtils.escapeJson(responseMessage) : "");
92
                 "/" + StringEscapeUtils.escapeJson(responseMessage) : "");
85
        if (isSuccessCode(responseCode)) {
93
        if (isSuccessCode(responseCode) || 
94
                (StringUtils.isEmpty(responseCode) && 
95
                        !StringUtils.isEmpty(sample.getFailureMessage()))) {
86
            key = ASSERTION_FAILED;
96
            key = ASSERTION_FAILED;
87
            if (ASSERTION_RESULTS_FAILURE_MESSAGE) {
97
            if (ASSERTION_RESULTS_FAILURE_MESSAGE) {
88
                String msg = sample.getFailureMessage();
98
                String msg = sample.getFailureMessage();
Lines 93-99 Link Here
93
        }
103
        }
94
        return key;
104
        return key;
95
    }
105
    }
96
97
    /*
106
    /*
98
     * (non-Javadoc)
107
     * (non-Javadoc)
99
     * 
108
     * 
(-)src/core/org/apache/jmeter/report/processor/Top5ErrorsBySamplerConsumer.java (-20 / +1 lines)
Lines 17-24 Link Here
17
 */
17
 */
18
package org.apache.jmeter.report.processor;
18
package org.apache.jmeter.report.processor;
19
19
20
import org.apache.commons.lang3.StringEscapeUtils;
21
import org.apache.commons.lang3.StringUtils;
22
import org.apache.jmeter.report.core.Sample;
20
import org.apache.jmeter.report.core.Sample;
23
import org.apache.jmeter.util.JMeterUtils;
21
import org.apache.jmeter.util.JMeterUtils;
24
22
Lines 57-84 Link Here
57
        }
55
        }
58
        
56
        
59
        if(!sample.getSuccess()) {
57
        if(!sample.getSuccess()) {
60
            data.registerError(getError(sample));
58
            data.registerError(ErrorsSummaryConsumer.getErrorKey(sample));
61
            data.incErrors();
59
            data.incErrors();
62
        }
60
        }
63
        data.incTotal();
61
        data.incTotal();
64
    }
62
    }
65
    
66
    private String getError(Sample sample) {
67
        String responseCode = sample.getResponseCode();
68
        String responseMessage = sample.getResponseMessage();
69
        String key = responseCode + (!StringUtils.isEmpty(responseMessage) ? 
70
                 "/" + StringEscapeUtils.escapeJson(responseMessage) : "");
71
        if (ErrorsSummaryConsumer.isSuccessCode(responseCode)) {
72
            key = ErrorsSummaryConsumer.ASSERTION_FAILED;
73
            if (ErrorsSummaryConsumer.ASSERTION_RESULTS_FAILURE_MESSAGE) {
74
                String msg = sample.getFailureMessage();
75
                if (!StringUtils.isEmpty(msg)) {
76
                    key = StringEscapeUtils.escapeJson(msg);
77
                }
78
            }
79
        }
80
        return key;
81
    }
82
63
83
    /*
64
    /*
84
     * (non-Javadoc)
65
     * (non-Javadoc)
(-)test/src/org/apache/jmeter/report/processor/ErrorsSummaryConsumerTest.java (+18 lines)
Lines 26-31 Link Here
26
public class ErrorsSummaryConsumerTest {
26
public class ErrorsSummaryConsumerTest {
27
27
28
    @Test
28
    @Test
29
    public void testGetErrorKey() {
30
        SampleMetadata metadata = new SampleMetadata(',', new String[] { CSVSaveService.SUCCESSFUL,
31
                CSVSaveService.RESPONSE_CODE, CSVSaveService.RESPONSE_MESSAGE, CSVSaveService.FAILURE_MESSAGE });
32
        Sample sample = new Sample(0, metadata, new String[] { "false", "", "", "FailureMessage" });
33
        Assert.assertEquals("FailureMessage", ErrorsSummaryConsumer.getErrorKey(sample));
34
35
        sample = new Sample(0, metadata, new String[] { "false", "200", "", "FailureMessage" });
36
        Assert.assertEquals("FailureMessage", ErrorsSummaryConsumer.getErrorKey(sample));
37
        
38
        sample = new Sample(0, metadata, new String[] { "true", "200", "", "" });
39
        Assert.assertEquals(ErrorsSummaryConsumer.ASSERTION_FAILED, ErrorsSummaryConsumer.getErrorKey(sample));
40
41
        sample = new Sample(0, metadata, new String[] { "false", "500", "Server Error", "FailureMessage" });
42
        Assert.assertEquals("500/Server Error", ErrorsSummaryConsumer.getErrorKey(sample));
43
    }
44
    
45
    
46
    @Test
29
    public void testErrorSampleCounter() {
47
    public void testErrorSampleCounter() {
30
        ErrorsSummaryConsumer consumer = new ErrorsSummaryConsumer();
48
        ErrorsSummaryConsumer consumer = new ErrorsSummaryConsumer();
31
        Sample sample = createSample(false);
49
        Sample sample = createSample(false);

Return to bug 61129