You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by mi...@apache.org on 2012/11/24 21:19:52 UTC

svn commit: r1413256 - in /jmeter/trunk: ./ bin/ src/components/org/apache/jmeter/assertions/ src/components/org/apache/jmeter/assertions/gui/ src/components/org/apache/jmeter/extractor/ src/components/org/apache/jmeter/extractor/gui/ src/components/or...

Author: milamber
Date: Sat Nov 24 20:19:50 2012
New Revision: 1413256

URL: http://svn.apache.org/viewvc?rev=1413256&view=rev
Log:
Add support of several document types (like Apache OpenOffice's files, MS Office's files, PDF's files, etc.) to the elements View Results Tree, Assertion Response and Regular Expression Extractor (in using Apache Tika)
Bugzilla Id: 54200

Added:
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsDocument.java   (with props)
    jmeter/trunk/src/core/org/apache/jmeter/util/Document.java   (with props)
Modified:
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/build.properties
    jmeter/trunk/build.xml
    jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java
    jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java
    jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java
    jmeter/trunk/src/components/org/apache/jmeter/extractor/gui/RegexExtractorGui.java
    jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
    jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1413256&r1=1413255&r2=1413256&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Sat Nov 24 20:19:50 2012
@@ -852,6 +852,10 @@ beanshell.server.file=../extras/startup.
 # Set to 0 to disable the size check
 #view.results.tree.max_size=0
 
+# Maximum size of Document that can be parsed by Tika engine; defaut=10 * 1024 * 1024 (10MB)
+# Set to 0 to disable the size check
+#document.max_size=0
+
 #JMS options
 # Enable the following property to stop JMS Point-to-Point Sampler from using
 # the properties java.naming.security.[principal|credentials] when creating the queue connection

Modified: jmeter/trunk/build.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/build.properties?rev=1413256&r1=1413255&r2=1413256&view=diff
==============================================================================
--- jmeter/trunk/build.properties (original)
+++ jmeter/trunk/build.properties Sat Nov 24 20:19:50 2012
@@ -213,6 +213,17 @@ tidy.jar                    = jtidy-${ti
 tidy.loc                    = ${maven2.repo}/net/sf/jtidy/jtidy/${tidy.version}
 tidy.md5                    = 6A9121561B8F98C0A8FB9B6E57F50E6B
 
+# Apache Tika to extract text from various documents
+tika-core.version           = 1.2
+tika-core.jar               = tika-core-${tika-core.version}.jar
+tika-core.loc               = ${maven2.repo}/org/apache/tika/tika-core/${tika-core.version}
+tika-core.md5               = 17cfec5a9b28b323375de0692ce5ecb1
+
+tika-parsers.version        = 1.2
+tika-parsers.jar            = tika-parsers-${tika-parsers.version}.jar
+tika-parsers.loc            = ${maven2.repo}/org/apache/tika/tika-parsers/${tika-parsers.version}
+tika-parsers.md5            = a15b071726358fd195d5c4b0625cdfb5
+
 # XStream can be found at: http://xstream.codehaus.org/
 xstream.version             = 1.4.2
 xstream.jar                 = xstream-${xstream.version}.jar
@@ -284,4 +295,4 @@ jms.md5                     = d80ce71285
 velocity.version            = 1.7
 velocity.jar                = velocity-${velocity.version}.jar
 velocity.loc                = ${maven2.repo}/org/apache/velocity/velocity/${velocity.version}
-velocity.md5                = 3692dd72f8367cb35fb6280dc2916725
\ No newline at end of file
+velocity.md5                = 3692dd72f8367cb35fb6280dc2916725

Modified: jmeter/trunk/build.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/build.xml?rev=1413256&r1=1413255&r2=1413256&view=diff
==============================================================================
--- jmeter/trunk/build.xml (original)
+++ jmeter/trunk/build.xml Sat Nov 24 20:19:50 2012
@@ -382,6 +382,8 @@
     <include name="${lib.dir}/${serializer.jar}"/>
     <include name="${lib.dir}/${soap.jar}"/>
     <include name="${lib.dir}/${tidy.jar}"/>
+    <include name="${lib.dir}/${tika-core.jar}"/>
+    <include name="${lib.dir}/${tika-parsers.jar}"/>
     <include name="${lib.dir}/${xalan.jar}"/>
     <include name="${lib.dir}/${xerces.jar}"/>
     <include name="${lib.dir}/${xml-apis.jar}"/>
@@ -444,6 +446,8 @@
     <pathelement location="${lib.dir}/${serializer.jar}"/>
     <pathelement location="${lib.dir}/${soap.jar}"/>
     <pathelement location="${lib.dir}/${tidy.jar}"/>
+    <pathelement location="${lib.dir}/${tika-core.jar}"/>
+    <pathelement location="${lib.dir}/${tika-parsers.jar}"/>
     <pathelement location="${lib.dir}/${xalan.jar}"/>
     <pathelement location="${lib.dir}/${xerces.jar}"/>
     <pathelement location="${lib.dir}/${xml-apis.jar}"/>
@@ -2491,6 +2495,8 @@ run JMeter unless all the JMeter jars ar
         <process_jarfile jarname="serializer"/>
         <process_jarfile jarname="soap"/>
         <process_jarfile jarname="tidy"/>
+        <process_jarfile jarname="tika-core"/>
+        <process_jarfile jarname="tika-parsers"/>
         <process_jarfile jarname="velocity"   dest.dir="${lib.doc}"/>
         <process_jarfile jarname="xalan"/>
         <process_jarfile jarname="xerces"/>

Modified: jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java?rev=1413256&r1=1413255&r2=1413256&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/assertions/ResponseAssertion.java Sat Nov 24 20:19:50 2012
@@ -30,6 +30,7 @@ import org.apache.jmeter.testelement.pro
 import org.apache.jmeter.testelement.property.NullProperty;
 import org.apache.jmeter.testelement.property.PropertyIterator;
 import org.apache.jmeter.testelement.property.StringProperty;
+import org.apache.jmeter.util.Document;
 import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.log.Logger;
@@ -56,6 +57,8 @@ public class ResponseAssertion extends A
 
     private static final String RESPONSE_DATA = "Assertion.response_data"; // $NON-NLS-1$
 
+    private static final String RESPONSE_DATA_AS_DOCUMENT = "Assertion.response_data_as_document"; // $NON-NLS-1$
+
     private static final String RESPONSE_CODE = "Assertion.response_code"; // $NON-NLS-1$
 
     private static final String RESPONSE_MESSAGE = "Assertion.response_message"; // $NON-NLS-1$
@@ -124,6 +127,10 @@ public class ResponseAssertion extends A
         setTestField(RESPONSE_DATA);
     }
 
+    public void setTestFieldResponseDataAsDocument(){
+        setTestField(RESPONSE_DATA_AS_DOCUMENT);
+    }
+
     public void setTestFieldResponseMessage(){
         setTestField(RESPONSE_MESSAGE);
     }
@@ -144,6 +151,10 @@ public class ResponseAssertion extends A
         return RESPONSE_DATA.equals(getTestField());
     }
 
+    public boolean isTestFieldResponseDataAsDocument() {
+        return RESPONSE_DATA_AS_DOCUMENT.equals(getTestField());
+    }
+
     public boolean isTestFieldResponseMessage(){
         return RESPONSE_MESSAGE.equals(getTestField());
     }
@@ -295,6 +306,8 @@ public class ResponseAssertion extends A
             toCheck = getThreadContext().getVariables().get(getVariableName());
         } else if (isTestFieldResponseData()) {
             toCheck = response.getResponseDataAsString(); // (bug25052)
+        } else if (isTestFieldResponseDataAsDocument()) {
+            toCheck = Document.getTextFromDocument(response.getResponseData()); 
         } else if (isTestFieldResponseCode()) {
             toCheck = response.getResponseCode();
         } else if (isTestFieldResponseMessage()) {
@@ -387,6 +400,8 @@ public class ResponseAssertion extends A
             sb.append("message");
         } else if (isTestFieldResponseHeaders()) {
             sb.append("headers");
+        } else if (isTestFieldResponseDataAsDocument()) {
+            sb.append("document");
         } else // Assume it is the URL
         {
             sb.append("URL");

Modified: jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java?rev=1413256&r1=1413255&r2=1413256&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java Sat Nov 24 20:19:50 2012
@@ -55,6 +55,9 @@ public class AssertionGui extends Abstra
     /** Radio button indicating that the text response should be tested. */
     private JRadioButton responseStringButton;
 
+    /** Radio button indicating that the text of a document should be tested. */
+    private JRadioButton responseAsDocumentButton;
+
     /** Radio button indicating that the URL should be tested. */
     private JRadioButton urlButton;
 
@@ -144,6 +147,8 @@ public class AssertionGui extends Abstra
 
             if (responseStringButton.isSelected()) {
                 ra.setTestFieldResponseData();
+            } else if (responseAsDocumentButton.isSelected()) {
+                ra.setTestFieldResponseDataAsDocument();
             } else if (responseCodeButton.isSelected()) {
                 ra.setTestFieldResponseCode();
             } else if (responseMessageButton.isSelected()) {
@@ -224,6 +229,8 @@ public class AssertionGui extends Abstra
 
         if (model.isTestFieldResponseData()) {
             responseStringButton.setSelected(true);
+        } else if (model.isTestFieldResponseDataAsDocument()) {
+            responseAsDocumentButton.setSelected(true);
         } else if (model.isTestFieldResponseCode()) {
             responseCodeButton.setSelected(true);
         } else if (model.isTestFieldResponseMessage()) {
@@ -279,6 +286,7 @@ public class AssertionGui extends Abstra
         panel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("assertion_resp_field"))); //$NON-NLS-1$
 
         responseStringButton = new JRadioButton(JMeterUtils.getResString("assertion_text_resp")); //$NON-NLS-1$
+        responseAsDocumentButton = new JRadioButton(JMeterUtils.getResString("assertion_text_document")); //$NON-NLS-1$
         urlButton = new JRadioButton(JMeterUtils.getResString("assertion_url_samp")); //$NON-NLS-1$
         responseCodeButton = new JRadioButton(JMeterUtils.getResString("assertion_code_resp")); //$NON-NLS-1$
         responseMessageButton = new JRadioButton(JMeterUtils.getResString("assertion_message_resp")); //$NON-NLS-1$
@@ -286,12 +294,14 @@ public class AssertionGui extends Abstra
 
         ButtonGroup group = new ButtonGroup();
         group.add(responseStringButton);
+        group.add(responseAsDocumentButton);
         group.add(urlButton);
         group.add(responseCodeButton);
         group.add(responseMessageButton);
         group.add(responseHeadersButton);
 
         panel.add(responseStringButton);
+        panel.add(responseAsDocumentButton);
         panel.add(urlButton);
         panel.add(responseCodeButton);
         panel.add(responseMessageButton);

Modified: jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java?rev=1413256&r1=1413255&r2=1413256&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java Sat Nov 24 20:19:50 2012
@@ -29,6 +29,7 @@ import org.apache.jmeter.testelement.Abs
 import org.apache.jmeter.testelement.property.IntegerProperty;
 import org.apache.jmeter.threads.JMeterContext;
 import org.apache.jmeter.threads.JMeterVariables;
+import org.apache.jmeter.util.Document;
 import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.log.Logger;
@@ -62,6 +63,7 @@ public class RegexExtractor extends Abst
     public static final String USE_HDRS = "true"; // $NON-NLS-1$
     public static final String USE_BODY = "false"; // $NON-NLS-1$
     public static final String USE_BODY_UNESCAPED = "unescaped"; // $NON-NLS-1$
+    public static final String USE_BODY_AS_DOCUMENT = "as_document"; // $NON-NLS-1$
     public static final String USE_URL = "URL"; // $NON-NLS-1$
     public static final String USE_CODE = "code"; // $NON-NLS-1$
     public static final String USE_MESSAGE = "message"; // $NON-NLS-1$
@@ -89,6 +91,7 @@ public class RegexExtractor extends Abst
      *
      * @see org.apache.jmeter.processor.PostProcessor#process()
      */
+    @Override
     public void process() {
         initTemplate();
         JMeterContext context = getThreadContext();
@@ -168,6 +171,7 @@ public class RegexExtractor extends Abst
                 : useCode() ? result.getResponseCode() // Bug 43451
                 : useMessage() ? result.getResponseMessage() // Bug 43451
                 : useUnescapedBody() ? StringEscapeUtils.unescapeHtml4(result.getResponseDataAsString())
+                : useBodyAsDocument() ? Document.getTextFromDocument(result.getResponseData())
                 : result.getResponseDataAsString() // Bug 36898
                 ;
        if (log.isDebugEnabled()) {
@@ -435,6 +439,11 @@ public class RegexExtractor extends Abst
         return USE_BODY_UNESCAPED.equalsIgnoreCase(prop);// $NON-NLS-1$
     }
 
+    public boolean useBodyAsDocument() {
+        String prop = getPropertyAsString(MATCH_AGAINST);
+        return USE_BODY_AS_DOCUMENT.equalsIgnoreCase(prop);// $NON-NLS-1$
+    }
+
     public boolean useUrl() {
         String prop = getPropertyAsString(MATCH_AGAINST);
         return USE_URL.equalsIgnoreCase(prop);

Modified: jmeter/trunk/src/components/org/apache/jmeter/extractor/gui/RegexExtractorGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/extractor/gui/RegexExtractorGui.java?rev=1413256&r1=1413255&r2=1413256&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/extractor/gui/RegexExtractorGui.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/extractor/gui/RegexExtractorGui.java Sat Nov 24 20:19:50 2012
@@ -57,6 +57,8 @@ public class RegexExtractorGui extends A
 
     private JRadioButton useUnescapedBody;
 
+    private JRadioButton useBodyAsDocument;
+
     private JRadioButton useHeaders;
 
     private JRadioButton useURL;
@@ -85,6 +87,7 @@ public class RegexExtractorGui extends A
             useHeaders.setSelected(re.useHeaders());
             useBody.setSelected(re.useBody());
             useUnescapedBody.setSelected(re.useUnescapedBody());
+            useBodyAsDocument.setSelected(re.useBodyAsDocument());
             useURL.setSelected(re.useUrl());
             useCode.setSelected(re.useCode());
             useMessage.setSelected(re.useMessage());
@@ -158,6 +161,7 @@ public class RegexExtractorGui extends A
 
         useBody = new JRadioButton(JMeterUtils.getResString("regex_src_body")); //$NON-NLS-1$
         useUnescapedBody = new JRadioButton(JMeterUtils.getResString("regex_src_body_unescaped")); //$NON-NLS-1$
+        useBodyAsDocument = new JRadioButton(JMeterUtils.getResString("regex_src_body_as_document")); //$NON-NLS-1$
         useHeaders = new JRadioButton(JMeterUtils.getResString("regex_src_hdrs")); //$NON-NLS-1$
         useURL = new JRadioButton(JMeterUtils.getResString("regex_src_url")); //$NON-NLS-1$
         useCode = new JRadioButton(JMeterUtils.getResString("assertion_code_resp")); //$NON-NLS-1$
@@ -166,6 +170,7 @@ public class RegexExtractorGui extends A
         group = new ButtonGroup();
         group.add(useBody);
         group.add(useUnescapedBody);
+        group.add(useBodyAsDocument);
         group.add(useHeaders);
         group.add(useURL);
         group.add(useCode);
@@ -173,6 +178,7 @@ public class RegexExtractorGui extends A
 
         panel.add(useBody);
         panel.add(useUnescapedBody);
+        panel.add(useBodyAsDocument);
         panel.add(useHeaders);
         panel.add(useURL);
         panel.add(useCode);
@@ -183,6 +189,7 @@ public class RegexExtractorGui extends A
         // So we know which button is selected
         useBody.setActionCommand(RegexExtractor.USE_BODY);
         useUnescapedBody.setActionCommand(RegexExtractor.USE_BODY_UNESCAPED);
+        useBodyAsDocument.setActionCommand(RegexExtractor.USE_BODY_AS_DOCUMENT);
         useHeaders.setActionCommand(RegexExtractor.USE_HDRS);
         useURL.setActionCommand(RegexExtractor.USE_URL);
         useCode.setActionCommand(RegexExtractor.USE_CODE);

Added: jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsDocument.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsDocument.java?rev=1413256&view=auto
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsDocument.java (added)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsDocument.java Sat Nov 24 20:19:50 2012
@@ -0,0 +1,63 @@
+/*
+ * 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.io.IOException;
+
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.util.Document;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+import org.apache.tika.exception.TikaException;
+import org.xml.sax.SAXException;
+
+public class RenderAsDocument extends SamplerResultTab implements ResultRenderer {
+
+    private static final Logger log = LoggingManager.getLoggerForClass();
+    
+    /** {@inheritDoc} */
+    @Override
+    public void renderResult(SampleResult sampleResult) {
+        try {
+            showDocumentResponse(sampleResult);
+        } catch (Exception e) {
+            results.setText(e.toString());
+            log.error("Error:", e); // $NON-NLS-1$
+        }
+    }
+
+    private void showDocumentResponse(SampleResult sampleResult)
+            throws IOException, SAXException, TikaException {
+        String response = Document.getTextFromDocument(sampleResult.getResponseData());
+
+        results.setContentType("text/plain"); // $NON-NLS-1$
+        results.setText(response);
+        results.setCaretPosition(0);
+        resultsScrollPane.setViewportView(results);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String toString() {
+        return JMeterUtils.getResString("view_results_render_document"); // $NON-NLS-1$
+    }
+
+}

Propchange: jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsDocument.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsDocument.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1413256&r1=1413255&r2=1413256&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Sat Nov 24 20:19:50 2012
@@ -112,6 +112,7 @@ assertion_patterns_to_test=Patterns to T
 assertion_resp_field=Response Field to Test
 assertion_resp_size_field=Response Size Field to Test
 assertion_substring=Substring
+assertion_text_document=Document (text)
 assertion_text_resp=Text Response
 assertion_textarea_label=Assertions\:
 assertion_title=Response Assertion
@@ -727,6 +728,7 @@ regex_extractor_title=Regular Expression
 regex_field=Regular Expression\:
 regex_source=Response Field to check
 regex_src_body=Body
+regex_src_body_as_document=Body as a Document
 regex_src_body_unescaped=Body (unescaped)
 regex_src_hdrs=Headers
 regex_src_url=URL
@@ -1111,6 +1113,7 @@ view_results_in_table=View Results in Ta
 view_results_latency=Latency: 
 view_results_load_time=Load time: 
 view_results_render=Render: 
+view_results_render_document=Document
 view_results_render_html=HTML
 view_results_render_html_embedded=HTML (download resources)
 view_results_render_json=JSON
@@ -1120,6 +1123,7 @@ view_results_request_headers=Request Hea
 view_results_response_code=Response code: 
 view_results_response_headers=Response headers:
 view_results_response_message=Response message: 
+view_results_response_missing_tika=Missing tika-app.jar in classpath. Unable to convert to plain text this kind of document.\nDownload the tika-app-x.x.jar file from http://tika.apache.org/download.html\nAnd put the file in <JMeter>/lib directory.
 view_results_response_partial_message=Start of message:
 view_results_response_too_large_message=Response too large to be displayed. Size: 
 view_results_sample_count=Sample Count: 

Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties?rev=1413256&r1=1413255&r2=1413256&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties Sat Nov 24 20:19:50 2012
@@ -106,6 +106,7 @@ assertion_patterns_to_test=Motifs \u00E0
 assertion_resp_field=Section de r\u00E9ponse \u00E0 tester
 assertion_resp_size_field=Taille \u00E0 v\u00E9rifier sur
 assertion_substring=Contient (texte brut)
+assertion_text_document=Document (texte)
 assertion_text_resp=Texte de r\u00E9ponse
 assertion_textarea_label=Assertions \:
 assertion_title=Assertion R\u00E9ponse
@@ -721,6 +722,7 @@ regex_extractor_title=Extracteur Express
 regex_field=Expression r\u00E9guli\u00E8re \:
 regex_source=Port\u00E9e
 regex_src_body=Corps
+regex_src_body_as_document=Corps en tant que Document
 regex_src_body_unescaped=Corps (non \u00E9chapp\u00E9)
 regex_src_hdrs=Ent\u00EAtes
 regex_src_url=URL
@@ -1105,6 +1107,7 @@ view_results_in_table=Tableau de r\u00E9
 view_results_latency=Latence \: 
 view_results_load_time=Temps de r\u00E9ponse \: 
 view_results_render=Rendu \: 
+view_results_render_document=Document
 view_results_render_html=HTML
 view_results_render_html_embedded=HTML et ressources
 view_results_render_json=JSON
@@ -1114,6 +1117,7 @@ view_results_request_headers=Ent\u00EAte
 view_results_response_code=Code de retour \: 
 view_results_response_headers=Ent\u00EAtes de r\u00E9ponse \:
 view_results_response_message=Message de retour \: 
+view_results_response_missing_tika=Manque l'archive tika-app.jar dans le classpath. Impossible de convertir en texte ce type de document.\nT\u00E9l\u00E9charger le fichier tika-app-x.x.jar depuis http\://tika.apache.org/download.html\nPuis ajouter ce file dans le r\u00E9pertoire <JMeter>/lib
 view_results_response_partial_message=D\u00E9but du message\:
 view_results_response_too_large_message=R\u00E9ponse d\u00E9passant la taille maximale d'affichage. Taille \: 
 view_results_sample_count=Compteur \u00E9chantillon \: 

Added: jmeter/trunk/src/core/org/apache/jmeter/util/Document.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/Document.java?rev=1413256&view=auto
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/util/Document.java (added)
+++ jmeter/trunk/src/core/org/apache/jmeter/util/Document.java Sat Nov 24 20:19:50 2012
@@ -0,0 +1,84 @@
+/* 
+ * 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.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.parser.AutoDetectParser;
+import org.apache.tika.parser.ParseContext;
+import org.apache.tika.parser.Parser;
+import org.apache.tika.sax.BodyContentHandler;
+import org.xml.sax.ContentHandler;
+
+public class Document {
+    
+    private static final Logger log = LoggingManager.getLoggerForClass();
+    
+    // Maximum size to convert a document to text (default 10Mb)
+    private static final int MAX_DOCUMENT_SIZE =
+        JMeterUtils.getPropDefault("document.max_size", 10 * 1024 * 1024); // $NON-NLS-1$
+
+    /**
+     * Convert to text plain a lot of kind of document
+     * (like odt, ods, odp, doc(x), xls(x), ppt(x), pdf, mp3, mp4, etc.) with Apache Tika
+     * @param document 
+     * @return text from document without format
+     */
+    public static String getTextFromDocument(byte[] document) {
+        String errMissingTika = JMeterUtils.getResString("view_results_response_missing_tika"); // $NON-NLS-1$
+        String response = errMissingTika;
+        Parser parser = new AutoDetectParser();
+        ContentHandler handler = new BodyContentHandler(MAX_DOCUMENT_SIZE > 0 ? MAX_DOCUMENT_SIZE : -1); // -1 to disable the write limit
+        Metadata metadata = new Metadata();
+        ParseContext context = new ParseContext();
+        InputStream stream = new ByteArrayInputStream(document); // open the stream
+        try {
+            parser.parse(stream, handler, metadata, context);
+            response = handler.toString();
+        } catch (Exception e) {
+            response = e.toString();
+            log.warn("Error document parsing:", e);
+        } catch (NoClassDefFoundError e) {
+            // put a warning if tika-app.jar missing (or some dependencies in only tika-core|parsers packages are using)
+            if (!System.getProperty("java.class.path").contains("tika-app")) { // $NON-NLS-1$ $NON-NLS-2$ 
+                log.warn(errMissingTika);
+            } else {
+                log.warn(errMissingTika, e);
+            }
+        } finally {
+            try {
+                stream.close(); // close the stream
+            } catch (IOException ioe) {
+                log.warn("Error closing document stream", ioe);// $NON-NLS-1$
+            }
+        }
+
+        if (response.length() == 0 && document.length > 0) {
+            log.warn("Probably: " + errMissingTika);// $NON-NLS-1$
+            response = errMissingTika;
+        }
+        return response;
+    }
+}

Propchange: jmeter/trunk/src/core/org/apache/jmeter/util/Document.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jmeter/trunk/src/core/org/apache/jmeter/util/Document.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1413256&r1=1413255&r2=1413256&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sat Nov 24 20:19:50 2012
@@ -179,6 +179,8 @@ and right angle bracket (&gt;) in search
 
 <h3>Listeners</h3>
 <ul>
+<li><bugzilla>54200</bugzilla> - Add support of several document types (like Apache OpenOffice's files, MS Office's files, PDF's files, etc.) 
+to the elements View Results Tree, Assertion Response and Regular Expression Extractor (in using Apache Tika)</li>
 </ul>
 
 <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>