From jmeter-dev-returnjennifer75@example.com Tue Dec 01 00:48:38 2009 Return-Path: <jmeter-dev-returnjennifer75@example.com> Delivered-To: jennifer75@example.com Received: (qmail 57881 invoked from network); 1 Dec 2009 00:48:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 1 Dec 2009 00:48:38 -0000 Received: (qmail 37300 invoked by uid 500); 1 Dec 2009 00:48:37 -0000 Delivered-To: jennifer75@example.com Received: (qmail 37264 invoked by uid 500); 1 Dec 2009 00:48:37 -0000 Mailing-List: contact jennifer75@example.com; run by ezmlm Precedence: bulk List-Unsubscribe: <mailto:jennifer75@example.com> List-Help: <mailto:jennifer75@example.com> List-Post: <mailto:jennifer75@example.com> List-Id: "JMeter Developers List" <jmeter-dev.jakarta.apache.org> Reply-To: "JMeter Developers List" <jennifer75@example.com> Delivered-To: mailing list jennifer75@example.com Received: (qmail 37254 invoked by uid 99); 1 Dec 2009 00:48:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Dec 2009 00:48:36 +0000 X-ASF-Spam-Status: No, hits=-10.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO brutus.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Dec 2009 00:48:34 +0000 Received: by brutus.apache.org (Postfix, from userid 33) id 7FD4F234C1F0; Mon, 30 Nov 2009 16:48:14 -0800 (PST) From: jennifer75@example.com To: jennifer75@example.com Subject: DO NOT REPLY [Bug 48300] Allow JMeter HTTP Request HTTPClient to use several source IP addresses (IP aliasing or network interfaces) X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: JMeter X-Bugzilla-Component: HTTP X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jennifer75@example.com X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: jennifer75@example.com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: In-Reply-To: <jennifer75@example.com/bugzilla/> References: <jennifer75@example.com/bugzilla/> X-Bugzilla-URL: https://issues.apache.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Message-Id: <jennifer75@example.com> Date: Mon, 30 Nov 2009 16:48:14 -0800 (PST) https://issues.apache.org/bugzilla/show_bug.cgi?id=48300 --- Comment #4 from Mark Thomas <jennifer75@example.com> 2009-11-30 16:48:13 GMT --- Note that due to a data loss on 26/27 Nov 2009 the issue that was originally created as bug 48300 was lost. It has been re-created as bug 48311. -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: jennifer75@example.com For additional commands, e-mail: jennifer75@example.com From jmeter-dev-returnjennifer75@example.com Tue Dec 01 01:52:07 2009 Return-Path: <jmeter-dev-returnjennifer75@example.com> Delivered-To: jennifer75@example.com Received: (qmail 81686 invoked from network); 1 Dec 2009 01:52:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 1 Dec 2009 01:52:07 -0000 Received: (qmail 37294 invoked by uid 500); 1 Dec 2009 01:52:06 -0000 Delivered-To: jennifer75@example.com Received: (qmail 37178 invoked by uid 500); 1 Dec 2009 01:52:06 -0000 Mailing-List: contact jennifer75@example.com; run by ezmlm Precedence: bulk List-Unsubscribe: <mailto:jennifer75@example.com> List-Help: <mailto:jennifer75@example.com> List-Post: <mailto:jennifer75@example.com> List-Id: "JMeter Developers List" <jmeter-dev.jakarta.apache.org> Reply-To: "JMeter Developers List" <jennifer75@example.com> Delivered-To: mailing list jennifer75@example.com Received: (qmail 37157 invoked by uid 500); 1 Dec 2009 01:52:06 -0000 Received: (qmail 37151 invoked by uid 99); 1 Dec 2009 01:52:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Dec 2009 01:52:05 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Dec 2009 01:52:00 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B2F2F238898B; Tue, 1 Dec 2009 01:51:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r885648 [1/2] - in /jakarta/jmeter/trunk/src: components/org/apache/jmeter/visualizers/ core/org/apache/jmeter/resources/ jorphan/org/apache/jorphan/gui/ Date: Tue, 01 Dec 2009 01:51:29 -0000 To: jennifer75@example.com From: jennifer75@example.com X-Mailer: svnmailer-1.0.8 Message-Id: <jennifer75@example.com> Author: sebb Date: Tue Dec 1 01:51:15 2009 New Revision: 885648 URL: http://svn.apache.org/viewvc?rev=885648&view=rev Log: Bug 47474 - View Results Tree support for plugin renderers Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTML.java (with props) jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTMLWithEmbedded.java (with props) jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java (with props) jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsRegexp.java (with props) jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsText.java (with props) jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXML.java (with props) jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ResultRenderer.java (with props) jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SamplerResultTab.java (with props) jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/GuiUtils.java (with props) Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SearchTextExtension.java jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTML.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTML.java?rev=885648&view=auto ============================================================================== --- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTML.java (added) +++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTML.java Tue Dec 1 01:51:15 2009 @@ -0,0 +1,150 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jmeter.visualizers; + +import javax.swing.JEditorPane; +import javax.swing.text.ComponentView; +import javax.swing.text.Document; +import javax.swing.text.EditorKit; +import javax.swing.text.Element; +import javax.swing.text.StyleConstants; +import javax.swing.text.View; +import javax.swing.text.ViewFactory; +import javax.swing.text.html.HTML; +import javax.swing.text.html.HTMLEditorKit; + +import org.apache.jmeter.samplers.SampleResult; +import org.apache.jmeter.util.JMeterUtils; +import org.apache.jorphan.logging.LoggingManager; +import org.apache.log.Logger; + +public class RenderAsHTML extends SamplerResultTab implements ResultRenderer { + + private static final Logger log = LoggingManager.getLoggerForClass(); + + private static final String TEXT_HTML = "text/html"; // $NON-NLS-1$ + + // Keep copies of the two editors needed + private static final EditorKit customisedEditor = new LocalHTMLEditorKit(); + + private static final EditorKit defaultHtmlEditor = JEditorPane.createEditorKitForContentType(TEXT_HTML); + + /** {@inheritDoc} */ + public void renderResult(SampleResult sampleResult) { + // get the text response and image icon + // to determine which is NOT null + String response = ViewResultsFullVisualizer.getResponseAsString(sampleResult); + showRenderedResponse(response, sampleResult); + } + + protected void showRenderedResponse(String response, SampleResult res) { + showRenderedResponse(response, res, false); + } + + protected void showRenderedResponse(String response, SampleResult res, boolean embedded) { + if (response == null) { + results.setText(""); + return; + } + + int htmlIndex = response.indexOf("<HTML"); // could be <HTML lang=""> // $NON-NLS-1$ + + // Look for a case variation + if (htmlIndex < 0) { + htmlIndex = response.indexOf("<html"); // ditto // $NON-NLS-1$ + } + + // If we still can't find it, just try using all of the text + if (htmlIndex < 0) { + htmlIndex = 0; + } + + String html = response.substring(htmlIndex); + + /* + * To disable downloading and rendering of images and frames, enable the + * editor-kit. The Stream property can then be + */ + log.debug("html embedded=" + embedded); + // Must be done before setContentType + results.setEditorKitForContentType(TEXT_HTML, embedded ? defaultHtmlEditor : customisedEditor); + + results.setContentType(TEXT_HTML); + + if (embedded) { + // Allow JMeter to render frames (and relative images) + // Must be done after setContentType [Why?] + results.getDocument().putProperty(Document.StreamDescriptionProperty, res.getURL()); + } + /* + * Get round problems parsing <META http-equiv='content-type' + * content='text/html; charset=utf-8'> See + * http://issues.apache.org/bugzilla/show_bug.cgi?id=23315 + * + * Is this due to a bug in Java? + */ + results.getDocument().putProperty("IgnoreCharsetDirective", Boolean.TRUE); // $NON-NLS-1$ + + results.setText(html); + results.setCaretPosition(0); + resultsScrollPane.setViewportView(results); + + } + + private static class LocalHTMLEditorKit extends HTMLEditorKit { + + private static final long serialVersionUID = -3399554318202905392L; + + private static final ViewFactory defaultFactory = new LocalHTMLFactory(); + + @Override + public ViewFactory getViewFactory() { + return defaultFactory; + } + + private static class LocalHTMLFactory extends javax.swing.text.html.HTMLEditorKit.HTMLFactory { + /* + * Provide dummy implementations to suppress download and display of + * related resources: - FRAMEs - IMAGEs TODO create better dummy + * displays TODO suppress LINK somehow + */ + @Override + public View create(Element elem) { + Object o = elem.getAttributes().getAttribute(StyleConstants.NameAttribute); + if (o instanceof HTML.Tag) { + HTML.Tag kind = (HTML.Tag) o; + if (kind == HTML.Tag.FRAME) { + return new ComponentView(elem); + } else if (kind == HTML.Tag.IMG) { + return new ComponentView(elem); + } + } + return super.create(elem); + } + } + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return JMeterUtils.getResString("view_results_render_html"); // $NON-NLS-1$ + } + +} Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTML.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTML.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTMLWithEmbedded.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTMLWithEmbedded.java?rev=885648&view=auto ============================================================================== --- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTMLWithEmbedded.java (added) +++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTMLWithEmbedded.java Tue Dec 1 01:51:15 2009 @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jmeter.visualizers; + +import org.apache.jmeter.samplers.SampleResult; +import org.apache.jmeter.util.JMeterUtils; + +public class RenderAsHTMLWithEmbedded extends RenderAsHTML + implements ResultRenderer { + + /** {@inheritDoc} */ + @Override + protected void showRenderedResponse(String response, SampleResult res) { + // enable embedded html resources + showRenderedResponse(response, res, true); + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return JMeterUtils.getResString("view_results_render_html_embedded"); // $NON-NLS-1$ + } + +} Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTMLWithEmbedded.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTMLWithEmbedded.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java?rev=885648&view=auto ============================================================================== --- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java (added) +++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java Tue Dec 1 01:51:15 2009 @@ -0,0 +1,117 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jmeter.visualizers; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.jmeter.samplers.SampleResult; +import org.apache.jmeter.util.JMeterUtils; + +public class RenderAsJSON extends SamplerResultTab implements ResultRenderer { + + private static final String ESC_CHAR_REGEX = "\\\\[\"\\\\/bfnrt]|\\\\u[0-9A-Fa-f]{4}"; // $NON-NLS-1$ + + private static final String NORMAL_CHARACTER_REGEX = "[^\"\\\\]"; // $NON-NLS-1$ + + private static final String STRING_REGEX = "\"(" + ESC_CHAR_REGEX + "|" + NORMAL_CHARACTER_REGEX + ")*\""; // $NON-NLS-1$ + + // This 'other value' regex is deliberately weak, even accepting an empty string, to be useful when reporting malformed data. + private static final String OTHER_VALUE_REGEX = "[^\\{\\[\\]\\}\\,]*"; // $NON-NLS-1$ + + private static final String VALUE_OR_PAIR_REGEX = "((" + STRING_REGEX + "\\s*:)?\\s*(" + STRING_REGEX + "|" + OTHER_VALUE_REGEX + ")\\s*,?\\s*)"; // $NON-NLS-1$ + + private static final Pattern VALUE_OR_PAIR_PATTERN = Pattern.compile(VALUE_OR_PAIR_REGEX); + + /** {@inheritDoc} */ + public void renderResult(SampleResult sampleResult) { + String response = ViewResultsFullVisualizer.getResponseAsString(sampleResult); + showRenderJSONResponse(response); + } + + private void showRenderJSONResponse(String response) { + results.setContentType("text/plain"); // $NON-NLS-1$ + results.setText(response == null ? "" : prettyJSON(response)); + results.setCaretPosition(0); + resultsScrollPane.setViewportView(results); + } + + // It might be useful also to make this available in the 'Request' tab, for + // when posting JSON. + private static String prettyJSON(String json) { + StringBuffer pretty = new StringBuffer(json.length() * 2); // Educated guess + + final String tab = ": "; // $NON-NLS-1$ + StringBuffer index = new StringBuffer(); + String nl = ""; // $NON-NLS-1$ + + Matcher valueOrPair = VALUE_OR_PAIR_PATTERN.matcher(json); + + boolean misparse = false; + + for (int i = 0; i < json.length(); ) { + final char currentChar = json.charAt(i); + if ((currentChar == '{') || (currentChar == '[')) { + pretty.append(nl).append(index).append(currentChar); + i++; + index.append(tab); + misparse = false; + } + else if ((currentChar == '}') || (currentChar == ']')) { + if (index.length() > 0) { + index.delete(0, tab.length()); + } + pretty.append(nl).append(index).append(currentChar); + i++; + int j = i; + while ((j < json.length()) && Character.isWhitespace(json.charAt(j))) { + j++; + } + if ((j < json.length()) && (json.charAt(j) == ',')) { + pretty.append(","); // $NON-NLS-1$ + i=j+1; + } + misparse = false; + } + else if (valueOrPair.find(i) && valueOrPair.group().length() > 0) { + pretty.append(nl).append(index).append(valueOrPair.group()); + i=valueOrPair.end(); + misparse = false; + } + else { + if (!misparse) { + pretty.append(nl).append("- Parse failed from:"); + } + pretty.append(currentChar); + i++; + misparse = true; + } + nl = "\n"; // $NON-NLS-1$ + } + return pretty.toString(); + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return JMeterUtils.getResString("view_results_render_json"); // $NON-NLS-1$ + } + +} Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsRegexp.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsRegexp.java?rev=885648&view=auto ============================================================================== --- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsRegexp.java (added) +++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsRegexp.java Tue Dec 1 01:51:15 2009 @@ -0,0 +1,253 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * + */ +package org.apache.jmeter.visualizers; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.LinkedList; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextArea; + +import org.apache.jmeter.samplers.SampleResult; +import org.apache.jmeter.util.JMeterUtils; +import org.apache.jorphan.gui.GuiUtils; +import org.apache.jorphan.gui.JLabeledTextField; +import org.apache.jorphan.logging.LoggingManager; +import org.apache.log.Logger; +import org.apache.oro.text.PatternCacheLRU; +import org.apache.oro.text.regex.MatchResult; +import org.apache.oro.text.regex.Pattern; +import org.apache.oro.text.regex.PatternMatcherInput; +import org.apache.oro.text.regex.Perl5Compiler; +import org.apache.oro.text.regex.Perl5Matcher; + +/** + * Implement ResultsRender for Regexp tester + */ +public class RenderAsRegexp implements ResultRenderer, ActionListener { + + private static final Logger log = LoggingManager.getLoggerForClass(); + + private static final String REGEXP_TESTER_COMMAND = "regexp_tester"; // $NON-NLS-1$ + + private JPanel regexpPane; + + private JTextArea regexpDataField; + + private JLabeledTextField regexpField; + + private JTextArea regexpResultField; + + private JTabbedPane rightSide; + + private SampleResult sampleResult = null; + + /** {@inheritDoc} */ + public void clearData() { + this.clearFields(); + } + + /** {@inheritDoc} */ + public void init() { + // Create the panels for the regexp tab + regexpPane = createRegexpPanel(); + } + + /** + * Display the response as text or as rendered HTML. Change the text on the + * button appropriate to the current display. + * + * @param e the ActionEvent being processed + */ + public void actionPerformed(ActionEvent e) { + String command = e.getActionCommand(); + if ((sampleResult != null) && (REGEXP_TESTER_COMMAND.equals(command))) { + String response = ViewResultsFullVisualizer.getResponseAsString(sampleResult); + executeAndShowRegexpTester(response); + } + } + + /** + * Launch regexp engine to parse a input text + * @param textToParse + */ + private void executeAndShowRegexpTester(String textToParse) { + if (textToParse != null && textToParse.length() > 0 + && this.regexpField.getText().length() > 0) { + log.debug("regexpField = " + this.regexpField.getText()); + this.regexpResultField.setText(process(textToParse)); + } + } + + private String process(String textToParse) { + + Perl5Matcher matcher = new Perl5Matcher(); + PatternMatcherInput input = new PatternMatcherInput(textToParse); + + PatternCacheLRU pcLRU = new PatternCacheLRU(); + Pattern pattern = pcLRU.getPattern(regexpField.getText(), Perl5Compiler.READ_ONLY_MASK); + List<MatchResult> matches = new LinkedList<MatchResult>(); + int x = 0; + boolean done = false; + do { + if (matcher.contains(input, pattern)) { + //log.debug("RegexExtractor: Match found!"); + matches.add(matcher.getMatch()); + } else { + done = true; + } + x++; + } while (!done); + + // Construct a multi-line string with all matches + StringBuffer sb = new StringBuffer(); + for (int j = 0; j < matches.size(); j++) { + MatchResult mr = matches.get(j); + final int groups = mr.groups(); + for (int i = 0; i < groups; i++) { + sb.append(" group[" + j + "][" + i + "]=" + mr.group(i) + "\n"); + + } + } + return sb.toString(); + + } + /** {@inheritDoc} */ + public void renderResult(SampleResult sampleResult) { + this.clearFields(); + + if ((SampleResult.TEXT).equals(sampleResult.getDataType())) { + String response = ViewResultsFullVisualizer.getResponseAsString(sampleResult); + regexpDataField.setText(response); + regexpDataField.setCaretPosition(0); + } else { + regexpDataField.setText(JMeterUtils.getResString("regexp_render_no_text")); + } + } + + /** {@inheritDoc} */ + public void setupTabPane() { + // Add regexp tester pane + if (rightSide.indexOfTab(JMeterUtils.getResString("regexp_tester_title")) < 0) { // $NON-NLS-1$ + rightSide.addTab(JMeterUtils.getResString("regexp_tester_title"), regexpPane); // $NON-NLS-1$ + } + clearData(); + } + + /** + * @return RegExp Tester panel + */ + private JPanel createRegexpPanel() { + regexpDataField = new JTextArea(); + regexpDataField.setEditable(false); + regexpDataField.setLineWrap(true); + regexpDataField.setWrapStyleWord(true); + + JScrollPane regexpDataPane = GuiUtils.makeScrollPane(regexpDataField); + regexpDataPane.setMinimumSize(new Dimension(0, 200)); + + JPanel pane = new JPanel(new BorderLayout(0, 5)); + + JSplitPane mainSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, + regexpDataPane, createRegexpTasksPanel()); + mainSplit.setDividerLocation(300); + pane.add(mainSplit, BorderLayout.CENTER); + return pane; + } + + /** + * Create the Regexp task pane + * + * @return Regexp task pane + */ + private JPanel createRegexpTasksPanel() { + JPanel regexpActionPanel = new JPanel(); + regexpField = new JLabeledTextField(JMeterUtils.getResString("regexp_tester_field"), 30); // $NON-NLS-1$ + regexpActionPanel.add(regexpField, BorderLayout.WEST); + + JButton regexpTester = new JButton(JMeterUtils.getResString("regexp_tester_button_test")); + regexpTester.setActionCommand(REGEXP_TESTER_COMMAND); + regexpTester.addActionListener(this); + regexpActionPanel.add(regexpTester, BorderLayout.EAST); + + regexpResultField = new JTextArea(); + regexpResultField.setEditable(false); + regexpResultField.setLineWrap(true); + regexpResultField.setWrapStyleWord(true); + + JPanel regexpTasksPanel = new JPanel(new BorderLayout(0, 5)); + regexpTasksPanel.add(regexpActionPanel, BorderLayout.NORTH); + regexpTasksPanel.add(GuiUtils.makeScrollPane(regexpResultField), BorderLayout.CENTER); + + return regexpTasksPanel; + } + + private void clearFields() { + regexpDataField.setText(""); // $NON-NLS-1$ + // don't set empty to keep regexp + // regexpField.setText(""); // $NON-NLS-1$ + regexpResultField.setText(""); // $NON-NLS-1$ + } + + /** {@inheritDoc} */ + public synchronized void setRightSide(JTabbedPane side) { + rightSide = side; + } + + /** {@inheritDoc} */ + public synchronized void setSamplerResult(Object userObject) { + if (userObject instanceof SampleResult) { + sampleResult = (SampleResult) userObject; + } + } + + /** {@inheritDoc} */ + public void setLastSelectedTab(int index) { + // nothing to do + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return JMeterUtils.getResString("regexp_tester_title"); + } + + /** {@inheritDoc} */ + public void renderImage(SampleResult sampleResult) { + clearData(); + } + + /** {@inheritDoc} */ + public void setBackgroundColor(Color backGround) { + } + +} Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsRegexp.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsRegexp.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsText.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsText.java?rev=885648&view=auto ============================================================================== --- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsText.java (added) +++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsText.java Tue Dec 1 01:51:15 2009 @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jmeter.visualizers; + +import org.apache.jmeter.samplers.SampleResult; +import org.apache.jmeter.util.JMeterUtils; + +public class RenderAsText extends SamplerResultTab implements ResultRenderer { + + /** {@inheritDoc} */ + public void renderResult(SampleResult sampleResult) { + String response = ViewResultsFullVisualizer.getResponseAsString(sampleResult); + showTextResponse(response); + } + + private void showTextResponse(String response) { + results.setContentType("text/plain"); // $NON-NLS-1$ + results.setText(response == null ? "" : response); // $NON-NLS-1$ + results.setCaretPosition(0); + resultsScrollPane.setViewportView(results); + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return JMeterUtils.getResString("view_results_render_text"); + } + +} Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsText.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsText.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXML.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXML.java?rev=885648&view=auto ============================================================================== --- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXML.java (added) +++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXML.java Tue Dec 1 01:51:15 2009 @@ -0,0 +1,222 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jmeter.visualizers; + +import java.awt.Component; +import java.awt.GridLayout; +import java.io.ByteArrayInputStream; +import java.io.StringWriter; + +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTree; +import javax.swing.ToolTipManager; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.TreeSelectionModel; + +import org.apache.jmeter.samplers.SampleResult; +import org.apache.jmeter.util.JMeterUtils; +import org.apache.jmeter.util.XPathUtil; +import org.apache.jorphan.logging.LoggingManager; +import org.apache.jorphan.util.JOrphanUtils; +import org.apache.log.Logger; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.tidy.Tidy; +import org.xml.sax.SAXException; + +public class RenderAsXML extends SamplerResultTab + implements ResultRenderer { + + private static final Logger log = LoggingManager.getLoggerForClass(); + + private static final byte[] XML_PFX = "<?xml ".getBytes(); // $NON-NLS-1$ + + public RenderAsXML(){ + activateSearchExtension = false; // TODO work out how to search the XML pane + } + + /** {@inheritDoc} */ + public void renderResult(SampleResult sampleResult) { + showRenderXMLResponse(sampleResult); + } + + private void showRenderXMLResponse(SampleResult res) { + results.setContentType("text/xml"); // $NON-NLS-1$ + results.setCaretPosition(0); + byte[] source = res.getResponseData(); + final ByteArrayInputStream baIS = new ByteArrayInputStream(source); + for(int i=0; i<source.length-XML_PFX.length; i++){ + if (JOrphanUtils.startsWith(source, XML_PFX, i)){ + baIS.skip(i);// Skip the leading bytes (if any) + break; + } + } + + // there is also a javax.swing.text.Document class. + org.w3c.dom.Document document = null; + + StringWriter sw = new StringWriter(); + Tidy tidy = XPathUtil.makeTidyParser(true, true, true, sw); + document = tidy.parseDOM(baIS, null); + document.normalize(); + if (tidy.getParseErrors() > 0) { + showErrorMessageDialog(sw.toString(), + "Tidy: " + tidy.getParseErrors() + " errors, " + tidy.getParseWarnings() + " warnings", + JOptionPane.WARNING_MESSAGE); + } + + JPanel domTreePanel = new DOMTreePanel(document); + resultsScrollPane.setViewportView(domTreePanel); + } + + /** + * + * A Dom tree panel for to display response as tree view author <a + * href="mailto:jennifer75@example.com">Dave Maung</a> TODO implement to find any + * nodes in the tree using TreePath. + * + */ + private static class DOMTreePanel extends JPanel { + + private static final long serialVersionUID = 6871690021183779153L; + + private JTree domJTree; + + public DOMTreePanel(org.w3c.dom.Document document) { + super(new GridLayout(1, 0)); + try { + Node firstElement = getFirstElement(document); + DefaultMutableTreeNode top = new XMLDefaultMutableTreeNode(firstElement); + domJTree = new JTree(top); + + domJTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + domJTree.setShowsRootHandles(true); + JScrollPane domJScrollPane = new JScrollPane(domJTree); + domJTree.setAutoscrolls(true); + this.add(domJScrollPane); + ToolTipManager.sharedInstance().registerComponent(domJTree); + domJTree.setCellRenderer(new DomTreeRenderer()); + } catch (SAXException e) { + log.warn("", e); + } + + } + + /** + * Skip all DTD nodes, all prolog nodes. They dont support in tree view + * We let user to insert them however in DOMTreeView, we dont display it + * + * @param root + * @return + */ + private Node getFirstElement(Node parent) { + NodeList childNodes = parent.getChildNodes(); + Node toReturn = parent; // Must return a valid node, or may generate an NPE + for (int i = 0; i < childNodes.getLength(); i++) { + Node childNode = childNodes.item(i); + toReturn = childNode; + if (childNode.getNodeType() == Node.ELEMENT_NODE){ + break; + } + + } + return toReturn; + } + + /** + * This class is to view as tooltext. This is very useful, when the + * contents has long string and does not fit in the view. it will also + * automatically wrap line for each 100 characters since tool tip + * support html. author <a href="mailto:jennifer75@example.com">Dave Maung</a> + */ + private static class DomTreeRenderer extends DefaultTreeCellRenderer { + + private static final long serialVersionUID = 240210061375790195L; + + @Override + public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, + boolean leaf, int row, boolean phasFocus) { + super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, phasFocus); + + DefaultMutableTreeNode valueTreeNode = (DefaultMutableTreeNode) value; + setToolTipText(getHTML(valueTreeNode.toString(), "<br>", 100)); // $NON-NLS-1$ + return this; + } + + /** + * get the html + * + * @param str + * @param separator + * @param maxChar + * @return + */ + private String getHTML(String str, String separator, int maxChar) { + StringBuffer strBuf = new StringBuffer("<html><body bgcolor=\"yellow\"><b>"); // $NON-NLS-1$ + char[] chars = str.toCharArray(); + for (int i = 0; i < chars.length; i++) { + + if (i % maxChar == 0 && i != 0) { + strBuf.append(separator); + } + strBuf.append(encode(chars[i])); + + } + strBuf.append("</b></body></html>"); // $NON-NLS-1$ + return strBuf.toString(); + + } + + private String encode(char c) { + String toReturn = String.valueOf(c); + switch (c) { + case '<': // $NON-NLS-1$ + toReturn = "&lt;"; // $NON-NLS-1$ + break; + case '>': // $NON-NLS-1$ + toReturn = "&gt;"; // $NON-NLS-1$ + break; + case '\'': // $NON-NLS-1$ + toReturn = "&apos;"; // $NON-NLS-1$ + break; + case '\"': // $NON-NLS-1$ + toReturn = "&quot;"; // $NON-NLS-1$ + break; + + } + return toReturn; + } + } + } + + private static void showErrorMessageDialog(String message, String title, int messageType) { + JOptionPane.showMessageDialog(null, message, title, messageType); + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return JMeterUtils.getResString("view_results_render_xml"); + } + +} Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXML.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXML.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ResultRenderer.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ResultRenderer.java?rev=885648&view=auto ============================================================================== --- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ResultRenderer.java (added) +++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ResultRenderer.java Tue Dec 1 01:51:15 2009 @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * + */ +package org.apache.jmeter.visualizers; + +import java.awt.Color; + +import javax.swing.JTabbedPane; + +import org.apache.jmeter.samplers.SampleResult; + + +/** + * Interface to results render + */ +public interface ResultRenderer { + + public void clearData(); + + public void init(); + + public void setupTabPane(); + + public void setLastSelectedTab(int index); + + public void setRightSide(JTabbedPane rightSide); + + public void setSamplerResult(Object userObject); + + public void renderResult(SampleResult sampleResult); + + public void renderImage(SampleResult sampleResult); + + /** + * + * @return the string to be displayed by the ComboBox + */ + public String toString(); + + public void setBackgroundColor(Color backGround); + +} Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ResultRenderer.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ResultRenderer.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SamplerResultTab.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SamplerResultTab.java?rev=885648&view=auto ============================================================================== --- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SamplerResultTab.java (added) +++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SamplerResultTab.java Tue Dec 1 01:51:15 2009 @@ -0,0 +1,345 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jmeter.visualizers; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JEditorPane; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextArea; +import javax.swing.JTextPane; +import javax.swing.text.BadLocationException; +import javax.swing.text.Style; +import javax.swing.text.StyleConstants; +import javax.swing.text.StyledDocument; + +import org.apache.jmeter.assertions.AssertionResult; +import org.apache.jmeter.samplers.SampleResult; +import org.apache.jmeter.util.JMeterUtils; +import org.apache.jorphan.gui.GuiUtils; +import org.apache.jorphan.logging.LoggingManager; +import org.apache.log.Logger; + +public abstract class SamplerResultTab implements ResultRenderer { + + private static final Logger log = LoggingManager.getLoggerForClass(); + + // N.B. these are not multi-threaded, so don't make it static + private final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); // ISO format $NON-NLS-1$ + + private static final String NL = "\n"; // $NON-NLS-1$ + + public static final Color SERVER_ERROR_COLOR = Color.red; + + public static final Color CLIENT_ERROR_COLOR = Color.blue; + + public static final Color REDIRECT_COLOR = Color.green; + + protected static final String TEXT_COMMAND = "text"; // $NON-NLS-1$ + + private static final String STYLE_SERVER_ERROR = "ServerError"; // $NON-NLS-1$ + + private static final String STYLE_CLIENT_ERROR = "ClientError"; // $NON-NLS-1$ + + private static final String STYLE_REDIRECT = "Redirect"; // $NON-NLS-1$ + + protected JEditorPane results; + + private JTextPane stats; + + protected JScrollPane resultsScrollPane; + + private JPanel resultsPane; + + private JLabel imageLabel; + + private JPanel requestPane; + + private JTextArea sampleDataField; + + protected JTabbedPane rightSide; + + private int lastSelectedTab; + + private Object userObject = null; // Could be SampleResult or AssertionResult + + private SampleResult sampleResult = null; + + private AssertionResult assertionResult = null; + + protected SearchTextExtension searchTextExtension; + + private JPanel searchPanel = null; + + protected boolean activateSearchExtension = true; // most current subclasses can process text + + private Color backGround; + + public void clearData() { + results.setText("");// Response Data // $NON-NLS-1$ + sampleDataField.setText("");// Request Data // $NON-NLS-1$ + } + + public void init() { + rightSide.addTab(JMeterUtils.getResString("view_results_tab_sampler"), createResponseMetadataPanel()); // $NON-NLS-1$ + // Create the panels for the other tabs + requestPane = createRequestPanel(); + resultsPane = createResponseDataPanel(); + } + + public void setupTabPane() { + StyledDocument statsDoc = stats.getStyledDocument(); + try { + statsDoc.remove(0, statsDoc.getLength()); + sampleDataField.setText(""); // $NON-NLS-1$ + results.setText(""); // $NON-NLS-1$ + if (userObject instanceof SampleResult) { + sampleResult = (SampleResult) userObject; + // We are displaying a SampleResult + setupTabPaneForSampleResult(); + + // load time label + log.debug("valueChanged1 : load time - " + sampleResult.getTime()); + String sd = sampleResult.getSamplerData(); + if (sd != null) { + String rh = sampleResult.getRequestHeaders(); + if (rh != null) { + StringBuffer sb = new StringBuffer(sd.length() + rh.length() + 20); + sb.append(sd); + sb.append("\n"); //$NON-NLS-1$ + sb.append(JMeterUtils.getResString("view_results_request_headers")); //$NON-NLS-1$ + sb.append("\n"); //$NON-NLS-1$ + sb.append(rh); + sd = sb.toString(); + } + sampleDataField.setText(sd); + } + + StringBuffer statsBuff = new StringBuffer(200); + statsBuff.append(JMeterUtils.getResString("view_results_thread_name")).append(sampleResult.getThreadName()).append(NL); //$NON-NLS-1$ + String startTime = dateFormat.format(new Date(sampleResult.getStartTime())); + statsBuff.append(JMeterUtils.getResString("view_results_sample_start")).append(startTime).append(NL); //$NON-NLS-1$ + statsBuff.append(JMeterUtils.getResString("view_results_load_time")).append(sampleResult.getTime()).append(NL); //$NON-NLS-1$ + statsBuff.append(JMeterUtils.getResString("view_results_latency")).append(sampleResult.getLatency()).append(NL); //$NON-NLS-1$ + statsBuff.append(JMeterUtils.getResString("view_results_size_in_bytes")).append(sampleResult.getBytes()).append(NL); //$NON-NLS-1$ + statsBuff.append(JMeterUtils.getResString("view_results_sample_count")).append(sampleResult.getSampleCount()).append(NL); //$NON-NLS-1$ + statsBuff.append(JMeterUtils.getResString("view_results_error_count")).append(sampleResult.getErrorCount()).append(NL); //$NON-NLS-1$ + statsDoc.insertString(statsDoc.getLength(), statsBuff.toString(), null); + statsBuff = new StringBuffer(); // reset for reuse + + String responseCode = sampleResult.getResponseCode(); + log.debug("valueChanged1 : response code - " + responseCode); + + int responseLevel = 0; + if (responseCode != null) { + try { + responseLevel = Integer.parseInt(responseCode) / 100; + } catch (NumberFormatException numberFormatException) { + // no need to change the foreground color + } + } + + Style style = null; + switch (responseLevel) { + case 3: + style = statsDoc.getStyle(STYLE_REDIRECT); + break; + case 4: + style = statsDoc.getStyle(STYLE_CLIENT_ERROR); + break; + case 5: + style = statsDoc.getStyle(STYLE_SERVER_ERROR); + break; + } + + statsBuff.append(JMeterUtils.getResString("view_results_response_code")).append(responseCode).append(NL); //$NON-NLS-1$ + statsDoc.insertString(statsDoc.getLength(), statsBuff.toString(), style); + statsBuff = new StringBuffer(100); // reset for reuse + + // response message label + String responseMsgStr = sampleResult.getResponseMessage(); + + log.debug("valueChanged1 : response message - " + responseMsgStr); + statsBuff.append(JMeterUtils.getResString("view_results_response_message")).append(responseMsgStr).append(NL); //$NON-NLS-1$ + + statsBuff.append(NL); + statsBuff.append(JMeterUtils.getResString("view_results_response_headers")).append(NL); //$NON-NLS-1$ + statsBuff.append(sampleResult.getResponseHeaders()).append(NL); + statsBuff.append(NL); + final String samplerClass = sampleResult.getClass().getName(); + statsBuff.append(samplerClass.substring(1 + samplerClass.lastIndexOf('.'))).append(" "+ JMeterUtils.getResString("view_results_fields")).append(NL); //$NON-NLS-1$ + statsBuff.append("ContentType: ").append(sampleResult.getContentType()).append(NL); + statsBuff.append("DataEncoding: ").append(sampleResult.getDataEncodingNoDefault()).append(NL); + statsDoc.insertString(statsDoc.getLength(), statsBuff.toString(), null); + statsBuff = null; // Done + + // Reset search + if (activateSearchExtension) { + searchTextExtension.resetTextToFind(); + } + + } else if (userObject instanceof AssertionResult) { + assertionResult = (AssertionResult) userObject; + + // We are displaying an AssertionResult + setupTabPaneForAssertionResult(); + + if (log.isDebugEnabled()) { + log.debug("valueChanged1 : sample result - " + assertionResult); + } + + StringBuffer statsBuff = new StringBuffer(100); + statsBuff.append(JMeterUtils.getResString("view_results_assertion_error")).append(assertionResult.isError()).append(NL); //$NON-NLS-1$ + statsBuff.append(JMeterUtils.getResString("view_results_assertion_failure")).append(assertionResult.isFailure()).append(NL); //$NON-NLS-1$ + statsBuff.append(JMeterUtils.getResString("view_results_assertion_failure_message")).append(assertionResult.getFailureMessage()).append(NL); //$NON-NLS-1$ + statsDoc.insertString(statsDoc.getLength(), statsBuff.toString(), null); + statsBuff = null; + } + } catch (BadLocationException exc) { + log.error("Error setting statistics text", exc); + stats.setText(""); + } + } + + private void setupTabPaneForSampleResult() { + // Set the title for the first tab + rightSide.setTitleAt(0, JMeterUtils.getResString("view_results_tab_sampler")); //$NON-NLS-1$ + // Add the other tabs if not present + if(rightSide.indexOfTab(JMeterUtils.getResString("view_results_tab_request")) < 0) { // $NON-NLS-1$ + rightSide.addTab(JMeterUtils.getResString("view_results_tab_request"), requestPane); // $NON-NLS-1$ + } + if(rightSide.indexOfTab(JMeterUtils.getResString("view_results_tab_response")) < 0) { // $NON-NLS-1$ + rightSide.addTab(JMeterUtils.getResString("view_results_tab_response"), resultsPane); // $NON-NLS-1$ + } + // restore last selected tab + if (lastSelectedTab < rightSide.getTabCount()) { + rightSide.setSelectedIndex(lastSelectedTab); + } + } + + private void setupTabPaneForAssertionResult() { + // Set the title for the first tab + rightSide.setTitleAt(0, JMeterUtils.getResString("view_results_tab_assertion")); //$NON-NLS-1$ + // Remove the other tabs if present + int requestTabIndex = rightSide.indexOfTab(JMeterUtils.getResString("view_results_tab_request")); // $NON-NLS-1$ + if(requestTabIndex >= 0) { + rightSide.removeTabAt(requestTabIndex); + } + int responseTabIndex = rightSide.indexOfTab(JMeterUtils.getResString("view_results_tab_response")); // $NON-NLS-1$ + if(responseTabIndex >= 0) { + rightSide.removeTabAt(responseTabIndex); + } + } + + private Component createResponseMetadataPanel() { + stats = new JTextPane(); + stats.setEditable(false); + stats.setBackground(backGround); + + // Add styles to use for different types of status messages + StyledDocument doc = (StyledDocument) stats.getDocument(); + + Style style = doc.addStyle(STYLE_REDIRECT, null); + StyleConstants.setForeground(style, REDIRECT_COLOR); + + style = doc.addStyle(STYLE_CLIENT_ERROR, null); + StyleConstants.setForeground(style, CLIENT_ERROR_COLOR); + + style = doc.addStyle(STYLE_SERVER_ERROR, null); + StyleConstants.setForeground(style, SERVER_ERROR_COLOR); + + JScrollPane pane = GuiUtils.makeScrollPane(stats); + pane.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); + return pane; + } + + private JPanel createRequestPanel() { + sampleDataField = new JTextArea(); + sampleDataField.setEditable(false); + sampleDataField.setLineWrap(true); + sampleDataField.setWrapStyleWord(true); + + JPanel pane = new JPanel(new BorderLayout(0, 5)); + pane.add(GuiUtils.makeScrollPane(sampleDataField)); + return pane; + } + + private JPanel createResponseDataPanel() { + results = new JEditorPane(); + results.setEditable(false); + + resultsScrollPane = GuiUtils.makeScrollPane(results); + imageLabel = new JLabel(); + + JPanel panel = new JPanel(new BorderLayout()); + panel.add(resultsScrollPane, BorderLayout.CENTER); + + if (activateSearchExtension) { + // Add search text extension + searchTextExtension = new SearchTextExtension(); + searchTextExtension.init(panel); + searchPanel = searchTextExtension.createSearchTextExtensionPane(); + searchTextExtension.setResults(results); + searchPanel.setVisible(true); + panel.add(searchPanel, BorderLayout.PAGE_END); + } + + return panel; + } + + private void showImage(Icon image) { + imageLabel.setIcon(image); + resultsScrollPane.setViewportView(imageLabel); + } + + public synchronized void setSamplerResult(Object sample) { + userObject = sample; + } + + public synchronized void setRightSide(JTabbedPane side) { + rightSide = side; + } + + public void setLastSelectedTab(int index) { + lastSelectedTab = index; + } + + public void renderImage(SampleResult sampleResult) { + byte[] responseBytes = sampleResult.getResponseData(); + if (responseBytes != null) { + showImage(new ImageIcon(responseBytes)); //TODO implement other non-text types + } + } + + public void setBackgroundColor(Color backGround){ + this.backGround = backGround; + } +} \ No newline at end of file Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SamplerResultTab.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SamplerResultTab.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SearchTextExtension.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SearchTextExtension.java?rev=885648&r1=885647&r2=885648&view=diff ============================================================================== --- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SearchTextExtension.java (original) +++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SearchTextExtension.java Tue Dec 1 01:51:15 2009 @@ -1,18 +1,18 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. - * + * * See the License for the specific language governing permissions and * limitations under the License. */ @@ -24,8 +24,6 @@ import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.InputEvent; -import java.awt.event.KeyEvent; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -56,30 +54,21 @@ import org.apache.log.Logger; public class SearchTextExtension implements ActionListener, DocumentListener { - + private static final Logger log = LoggingManager.getLoggerForClass(); - - public static final String SEARCH_TEXT_COMMAND = "search_text"; // $NON-NLS-1$ - - public static final String DIALOG_SEARCH_SHOW_COMMAND = "show_search_dialog"; // $NON-NLS-1$ - - public static final String DIALOG_SEARCH_HIDE_COMMAND = "close_search_dialog"; // $NON-NLS-1$ - - private static final String SEARCH_SHOW_COMMAND = "show_search_text"; // $NON-NLS-1$ - - // set default command to Text - private String command = DIALOG_SEARCH_SHOW_COMMAND; - + + private static final String SEARCH_TEXT_COMMAND = "search_text"; // $NON-NLS-1$ + private static int LAST_POSITION_DEFAULT = 0; private int lastPosition = LAST_POSITION_DEFAULT; - + private final static Color HILIT_COLOR = Color.LIGHT_GRAY; - + private Highlighter selection; - + private Highlighter.HighlightPainter painter; - + private JLabel label; private JButton findButton; @@ -93,26 +82,15 @@ private String lastTextTofind; private boolean newSearch = false; - + private JEditorPane results; - + private JPanel searchPanel; - private boolean enabled = true; - - private JCheckBox showSearch; - public void init(JPanel resultsPane) { - // when CTRL-T is pressed, (un-)show search dialog box (only in results pane) - InputMap im = resultsPane - .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); - im.put(KeyStroke.getKeyStroke(KeyEvent.VK_T, - InputEvent.CTRL_MASK), SEARCH_SHOW_COMMAND); - ActionMap am = resultsPane.getActionMap(); - am.put(SEARCH_SHOW_COMMAND, new DisplaySearchAction()); } - + public void setResults(JEditorPane results) { if (this.results != null) { newSearch = true; @@ -128,10 +106,10 @@ /** * Launch find text engine on response text */ - public void executeAndShowTextFind() { + private void executeAndShowTextFind() { + String textToFind = textToFindField.getText(); if (results != null && results.getText().length() > 0 - && this.textToFindField.getText().length() > 0) { - String textToFind = textToFindField.getText(); + && textToFind.length() > 0) { // new search? if (lastTextTofind != null && !lastTextTofind.equals(textToFind)) { @@ -153,7 +131,7 @@ selection.removeAllHighlights(); selection.addHighlight(lastPosition + matcher.start(), lastPosition + matcher.end(), painter); - results.setCaretPosition(lastPosition + matcher.end()); + results.setCaretPosition(lastPosition + matcher.end()); // save search position lastPosition = lastPosition + matcher.end(); @@ -180,12 +158,12 @@ /** * Create the text find task pane - * + * * @return Text find task pane */ - public JPanel createSearchTextPanel() { + private JPanel createSearchTextPanel() { Font font = new Font("SansSerif", Font.PLAIN, 10); - + // Search field searchPanel = new JPanel(); searchPanel.setLayout(new BoxLayout(searchPanel, BoxLayout.X_AXIS)); @@ -224,34 +202,18 @@ im.put(KeyStroke.getKeyStroke("ENTER"), SEARCH_TEXT_COMMAND); ActionMap am = textToFindField.getActionMap(); am.put(SEARCH_TEXT_COMMAND, new EnterAction()); - + + // default not visible + searchPanel.setVisible(true); return searchPanel; } - - public JPanel createSearchTextExtensionPane() { + + JPanel createSearchTextExtensionPane() { JPanel pane = new JPanel(); pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS)); - pane.add(createShowSearchPanel()); pane.add(createSearchTextPanel()); return pane; } - - public JPanel createShowSearchPanel() { - Font fontBold = new Font("SansSerif", Font.BOLD, 10); - - showSearch = new JCheckBox(); - showSearch.setFont(fontBold); - showSearch.setAction(new DisplaySearchAction()); - showSearch.setText(JMeterUtils - .getResString("view_results_search_pane")); // $NON-NLS-1$ - - JPanel pane = new JPanel(); - pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS)); - pane.add(showSearch); - - return pane; - } - /** * Display the response as text or as rendered HTML. Change the text on the @@ -261,18 +223,12 @@ * the ActionEvent being processed */ public void actionPerformed(ActionEvent e) { - command = e.getActionCommand(); + String command = e.getActionCommand(); // Search text in response data - if (command != null - && (command.equals(SearchTextExtension.SEARCH_TEXT_COMMAND))) { + if (SEARCH_TEXT_COMMAND.equals(command)) { executeAndShowTextFind(); } - // hide search dialog box - else if (command != null && command.equals( - SearchTextExtension.DIALOG_SEARCH_HIDE_COMMAND)) { - hideSearchBox(); - } } private class EnterAction extends AbstractAction { @@ -282,22 +238,6 @@ } } - private class DisplaySearchAction extends AbstractAction { - private static final long serialVersionUID = 1L; - public void actionPerformed(ActionEvent ev) { - if (searchPanel != null) { - resetTextToFind(); - if (searchPanel.isVisible()) { - searchPanel.setVisible(false); - showSearch.setSelected(false); - } else { - searchPanel.setVisible(true); - showSearch.setSelected(true); - } - } - } - } - // DocumentListener method public void changedUpdate(DocumentEvent e) { // do nothing @@ -313,11 +253,7 @@ resetTextToFind(); } - public void hideSearchBox() { - searchPanel.setVisible(false); - } - - public void resetTextToFind() { + void resetTextToFind() { if (newSearch) { log.debug("reset pass"); // Reset search @@ -330,22 +266,9 @@ newSearch = false; } } - - public boolean isEnabled() { - return enabled ; - } - - public void setEnabled(boolean b) { - this.enabled = b; - label.setEnabled(b); - textToFindField.setEnabled(b); - findButton.setEnabled(b); - caseChkBox.setEnabled(b); - regexpChkBox.setEnabled(b); - } - + private Pattern createPattern(String textToFind) { - // desactivate or not specials regexp char + // desactivate or not specials regexp char String textToFindQ = Pattern.quote(textToFind); if (regexpChkBox.isSelected()) { textToFindQ = textToFind; --------------------------------------------------------------------- To unsubscribe, e-mail: jennifer75@example.com For additional commands, e-mail: jennifer75@example.com From jmeter-dev-returnjennifer75@example.com Tue Dec 01 01:52:07 2009 Return-Path: <jmeter-dev-returnjennifer75@example.com> Delivered-To: jennifer75@example.com Received: (qmail 81688 invoked from network); 1 Dec 2009 01:52:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 1 Dec 2009 01:52:07 -0000 Received: (qmail 37245 invoked by uid 500); 1 Dec 2009 01:52:06 -0000 Delivered-To: jennifer75@example.com Received: (qmail 37175 invoked by uid 500); 1 Dec 2009 01:52:06 -0000 Mailing-List: contact jennifer75@example.com; run by ezmlm Precedence: bulk List-Unsubscribe: <mailto:jennifer75@example.com> List-Help: <mailto:jennifer75@example.com> List-Post: <mailto:jennifer75@example.com> List-Id: "JMeter Developers List" <jmeter-dev.jakarta.apache.org> Reply-To: "JMeter Developers List" <jennifer75@example.com> Delivered-To: mailing list jennifer75@example.com Received: (qmail 37156 invoked by uid 500); 1 Dec 2009 01:52:06 -0000 Received: (qmail 37149 invoked by uid 99); 1 Dec 2009 01:52:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Dec 2009 01:52:05 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Dec 2009 01:52:01 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B92C023889B5; Tue, 1 Dec 2009 01:51:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r885648 [2/2] - in /jakarta/jmeter/trunk/src: components/org/apache/jmeter/visualizers/ core/org/apache/jmeter/resources/ jorphan/org/apache/jorphan/gui/ Date: Tue, 01 Dec 2009 01:51:29 -0000 To: jennifer75@example.com From: jennifer75@example.com X-Mailer: svnmailer-1.0.8 Message-Id: <jennifer75@example.com> Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java?rev=885648&r1=885647&r2=885648&view=diff ============================================================================== --- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java (original) +++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java Tue Dec 1 01:51:15 2009 @@ -9,64 +9,39 @@ * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * * See the License for the specific language governing permissions and * limitations under the License. - * */ +/** + * + */ package org.apache.jmeter.visualizers; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; -import java.awt.Font; -import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.io.ByteArrayInputStream; -import java.io.StringWriter; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.ButtonGroup; -import javax.swing.Icon; +import java.io.IOException; +import java.util.Collections; +import java.util.List; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; import javax.swing.ImageIcon; -import javax.swing.JCheckBox; -import javax.swing.JEditorPane; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JRadioButton; +import javax.swing.JComboBox; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTabbedPane; -import javax.swing.JTextArea; -import javax.swing.JTextPane; import javax.swing.JTree; -import javax.swing.ToolTipManager; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.ComponentView; -import javax.swing.text.Document; -import javax.swing.text.EditorKit; -import javax.swing.text.Element; -import javax.swing.text.Style; -import javax.swing.text.StyleConstants; -import javax.swing.text.StyledDocument; -import javax.swing.text.View; -import javax.swing.text.ViewFactory; -import javax.swing.text.html.HTML; -import javax.swing.text.html.HTMLEditorKit; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeModel; @@ -74,127 +49,49 @@ import javax.swing.tree.TreeSelectionModel; import org.apache.jmeter.assertions.AssertionResult; +import org.apache.jmeter.gui.util.VerticalPanel; import org.apache.jmeter.samplers.Clearable; import org.apache.jmeter.samplers.SampleResult; import org.apache.jmeter.util.JMeterUtils; -import org.apache.jmeter.util.XPathUtil; import org.apache.jmeter.visualizers.gui.AbstractVisualizer; import org.apache.jorphan.logging.LoggingManager; -import org.apache.jorphan.util.JOrphanUtils; +import org.apache.jorphan.reflect.ClassFinder; import org.apache.log.Logger; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.tidy.Tidy; -import org.xml.sax.SAXException; /** - * Allows the tester to view the textual response from sampling an Entry. This - * also allows to "single step through" the sampling process via a nice - * "Continue" button. + * Base for ViewResults * - * Created 2001/07/25 */ public class ViewResultsFullVisualizer extends AbstractVisualizer - implements ActionListener, TreeSelectionListener, Clearable - { +implements ActionListener, TreeSelectionListener, Clearable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 7338676747296593842L; private static final Logger log = LoggingManager.getLoggerForClass(); - // Maximum size that we will display - private static final int MAX_DISPLAY_SIZE = - JMeterUtils.getPropDefault("view.results.tree.max_size", 200 * 1024); // $NON-NLS-1$ - - // N.B. these are not multi-threaded, so don't make it static - private final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); // ISO format $NON-NLS-1$ - - private static final String NL = "\n"; // $NON-NLS-1$ - - private static final byte[] XML_PFX = "<?xml ".getBytes(); // $NON-NLS-1$ - public static final Color SERVER_ERROR_COLOR = Color.red; public static final Color CLIENT_ERROR_COLOR = Color.blue; public static final Color REDIRECT_COLOR = Color.green; - private static final String TEXT_HTML = "text/html"; // $NON-NLS-1$ - - private static final String HTML_COMMAND = "html"; // $NON-NLS-1$ - - private static final String JSON_COMMAND = "json"; // $NON-NLS-1$ - - private static final String XML_COMMAND = "xml"; // $NON-NLS-1$ - - private static final String TEXT_COMMAND = "text"; // $NON-NLS-1$ - - private static final String STYLE_SERVER_ERROR = "ServerError"; // $NON-NLS-1$ - - private static final String STYLE_CLIENT_ERROR = "ClientError"; // $NON-NLS-1$ - - private static final String STYLE_REDIRECT = "Redirect"; // $NON-NLS-1$ - - private boolean textMode = true; - - private static final String ESC_CHAR_REGEX = "\\\\[\"\\\\/bfnrt]|\\\\u[0-9A-Fa-f]{4}"; // $NON-NLS-1$ - - private static final String NORMAL_CHARACTER_REGEX = "[^\"\\\\]"; // $NON-NLS-1$ - - private static final String STRING_REGEX = "\"(" + ESC_CHAR_REGEX + "|" + NORMAL_CHARACTER_REGEX + ")*\""; // $NON-NLS-1$ - - // This 'other value' regex is deliberately weak, even accepting an empty string, to be useful when reporting malformed data. - private static final String OTHER_VALUE_REGEX = "[^\\{\\[\\]\\}\\,]*"; // $NON-NLS-1$ - - private static final String VALUE_OR_PAIR_REGEX = "((" + STRING_REGEX + "\\s*:)?\\s*(" + STRING_REGEX + "|" + OTHER_VALUE_REGEX + ")\\s*,?\\s*)"; // $NON-NLS-1$ - - private static final Pattern VALUE_OR_PAIR_PATTERN = Pattern.compile(VALUE_OR_PAIR_REGEX); - - // set default command to Text - private String command = TEXT_COMMAND; - - // Keep copies of the two editors needed - private static final EditorKit customisedEditor = new LocalHTMLEditorKit(); - - private static final EditorKit defaultHtmlEditor = JEditorPane.createEditorKitForContentType(TEXT_HTML); + private JSplitPane mainSplit; private DefaultMutableTreeNode root; private DefaultTreeModel treeModel; - private JTextPane stats; - - private JEditorPane results; - - private JScrollPane resultsScrollPane; - - private JPanel resultsPane; - - private JLabel imageLabel; - - private JTextArea sampleDataField; - - private JPanel requestPane; - - private JRadioButton textButton; - - private JRadioButton htmlButton; - - private JRadioButton jsonButton; + private JTree jTree; - private JRadioButton xmlButton; + private Component leftSide; - private JCheckBox downloadAll; - - private JLabel renderLabel; + private JTabbedPane rightSide; - private JTree jTree; + private JComboBox selectRenderPanel; - private JTabbedPane rightSide; + private int selectedTab; - private SearchTextExtension searchTextExtension; - - private JPanel searchPanel = null; + protected static final String COMBO_CHANGE_COMMAND = "change_combo"; // $NON-NLS-1$ private static final ImageIcon imageSuccess = JMeterUtils.getImage( JMeterUtils.getPropDefault("viewResultsTree.success", //$NON-NLS-1$ @@ -204,29 +101,31 @@ JMeterUtils.getPropDefault("viewResultsTree.failure", //$NON-NLS-1$ "icon_warning_sml.gif")); //$NON-NLS-1$ + // Maximum size that we will display + private static final int MAX_DISPLAY_SIZE = + JMeterUtils.getPropDefault("view.results.tree.max_size", 200 * 1024); // $NON-NLS-1$ + + private ResultRenderer resultsRender = null; + + private TreeSelectionEvent lastSelectionEvent; + + /** + * Constructor + */ public ViewResultsFullVisualizer() { super(); - log.debug("Start : ViewResultsFullVisualizer1"); init(); - log.debug("End : ViewResultsFullVisualizer1"); - } - - public void add(SampleResult res) { - updateGui(res); } - public String getLabelResource() { - return "view_results_tree_title"; // $NON-NLS-1$ + /** {@inheritDoc} */ + public void add(SampleResult sample) { + updateGui(sample); } /** * Update the visualizer with new data. */ private synchronized void updateGui(SampleResult res) { - log.debug("Start : updateGui1"); - if (log.isDebugEnabled()) { - log.debug("updateGui1 : sample result - " + res); - } // Add sample DefaultMutableTreeNode currNode = new DefaultMutableTreeNode(res); treeModel.insertNodeInto(currNode, root, root.getChildCount()); @@ -246,7 +145,6 @@ if (root.getChildCount() == 1) { jTree.expandPath(new TreePath(root)); } - log.debug("End : updateGui1"); } private void addSubResults(DefaultMutableTreeNode currNode, SampleResult res) { @@ -278,314 +176,154 @@ } } - /** - * Clears the visualizer. - */ - public synchronized void clearData() { - log.debug("Start : clear1"); - - if (log.isDebugEnabled()) { - log.debug("clear1 : total child - " + root.getChildCount()); - } + /** {@inheritDoc} */ +
{'source': 'Apache Software Foundation Public Mail Archives'}