Author: pmouawad
Date: Fri Apr 15 14:33:32 2016
New Revision: 1739306

URL: http://svn.apache.org/viewvc?rev=1739306&view=rev
Log:
Bug 59331 - JMeter Report Generator : Add ability to set a title for the report 
Rename JMeter Dashboard to Apache JMeter Dashboard when property is not defined
Bugzilla Id: 59331

Modified:
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/bin/report-template/content/pages/OverTime.html.fmkr
    jmeter/trunk/bin/report-template/content/pages/ResponseTimes.html.fmkr
    jmeter/trunk/bin/report-template/content/pages/Throughput.html.fmkr
    jmeter/trunk/bin/report-template/index.html.fmkr
    jmeter/trunk/bin/user.properties
    
jmeter/trunk/src/core/org/apache/jmeter/report/config/ReportGeneratorConfiguration.java
    
jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/HtmlTemplateExporter.java
    jmeter/trunk/xdocs/usermanual/generating-dashboard.xml

Modified: jmeter/trunk/bin/jmeter.properties
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1739306&r1=1739305&r2=1739306&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Fri Apr 15 14:33:32 2016
@@ -1192,6 +1192,9 @@ classfinder.functions.notContain=.gui.
 # Caution : higher value provides a better accurency but needs more memory.
 #jmeter.reportgenerator.statistic_window = 200000
 
+# Configure this property to change the report title
+#jmeter.reportgenerator.report_title=Apache JMeter Dashboard
+
 # Defines the overall granularity for over time graphs
 jmeter.reportgenerator.overall_granularity=60000
 

Modified: jmeter/trunk/bin/report-template/content/pages/OverTime.html.fmkr
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/bin/report-template/content/pages/OverTime.html.fmkr?rev=1739306&r1=1739305&r2=1739306&view=diff
==============================================================================
--- jmeter/trunk/bin/report-template/content/pages/OverTime.html.fmkr (original)
+++ jmeter/trunk/bin/report-template/content/pages/OverTime.html.fmkr Fri Apr 
15 14:33:32 2016
@@ -9,7 +9,7 @@
     <meta name="description" content="">
     <meta name="author" content="">
 
-    <title>JMeter Dashboard</title>
+    <title>${reportTitle!"Apache JMeter Dashboard"}</title>
 
     <!-- Bootstrap Core CSS -->
     <link 
href="../../sbadmin2-1.0.7/bower_components/bootstrap/dist/css/bootstrap.min.css"
 rel="stylesheet">
@@ -49,7 +49,7 @@
                     <span class="icon-bar"></span>
                     <span class="icon-bar"></span>
                 </button>
-                <a class="navbar-brand" href="../../index.html">JMeter 
Dashboard</a>
+                <a class="navbar-brand" 
href="../../index.html">${reportTitle!"Apache JMeter Dashboard"}</a>
             </div>
             <!-- /.navbar-header -->
 

Modified: jmeter/trunk/bin/report-template/content/pages/ResponseTimes.html.fmkr
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/bin/report-template/content/pages/ResponseTimes.html.fmkr?rev=1739306&r1=1739305&r2=1739306&view=diff
==============================================================================
--- jmeter/trunk/bin/report-template/content/pages/ResponseTimes.html.fmkr 
(original)
+++ jmeter/trunk/bin/report-template/content/pages/ResponseTimes.html.fmkr Fri 
Apr 15 14:33:32 2016
@@ -9,7 +9,7 @@
     <meta name="description" content="">
     <meta name="author" content="">
 
-    <title>JMeter Dashboard</title>
+    <title>${reportTitle!"Apache JMeter Dashboard"}</title>
 
     <!-- Bootstrap Core CSS -->
     <link 
href="../../sbadmin2-1.0.7/bower_components/bootstrap/dist/css/bootstrap.min.css"
 rel="stylesheet">
@@ -49,7 +49,7 @@
                     <span class="icon-bar"></span>
                     <span class="icon-bar"></span>
                 </button>
-                <a class="navbar-brand" href="../../index.html">JMeter 
Dashboard</a>
+                <a class="navbar-brand" 
href="../../index.html">${reportTitle!"Apache JMeter Dashboard"}</a>
             </div>
             <!-- /.navbar-header -->
 

Modified: jmeter/trunk/bin/report-template/content/pages/Throughput.html.fmkr
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/bin/report-template/content/pages/Throughput.html.fmkr?rev=1739306&r1=1739305&r2=1739306&view=diff
==============================================================================
--- jmeter/trunk/bin/report-template/content/pages/Throughput.html.fmkr 
(original)
+++ jmeter/trunk/bin/report-template/content/pages/Throughput.html.fmkr Fri Apr 
15 14:33:32 2016
@@ -9,7 +9,7 @@
     <meta name="description" content="">
     <meta name="author" content="">
 
-    <title>JMeter Dashboard</title>
+    <title>${reportTitle!"Apache JMeter Dashboard"}</title>
 
     <!-- Bootstrap Core CSS -->
     <link 
href="../../sbadmin2-1.0.7/bower_components/bootstrap/dist/css/bootstrap.min.css"
 rel="stylesheet">
@@ -49,7 +49,7 @@
                     <span class="icon-bar"></span>
                     <span class="icon-bar"></span>
                 </button>
-                <a class="navbar-brand" href="../../index.html">JMeter 
Dashboard</a>
+                <a class="navbar-brand" 
href="../../index.html">${reportTitle!"Apache JMeter Dashboard"}</a>
             </div>
             <!-- /.navbar-header -->
 

Modified: jmeter/trunk/bin/report-template/index.html.fmkr
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/bin/report-template/index.html.fmkr?rev=1739306&r1=1739305&r2=1739306&view=diff
==============================================================================
--- jmeter/trunk/bin/report-template/index.html.fmkr (original)
+++ jmeter/trunk/bin/report-template/index.html.fmkr Fri Apr 15 14:33:32 2016
@@ -9,7 +9,7 @@
     <meta name="description" content="">
     <meta name="author" content="">
 
-    <title>JMeter Dashboard</title>
+    <title>${reportTitle!"Apache JMeter Dashboard"}</title>
 
      <!-- Bootstrap Core CSS -->
     <link 
href="sbadmin2-1.0.7/bower_components/bootstrap/dist/css/bootstrap.min.css" 
rel="stylesheet">
@@ -43,7 +43,7 @@
                     <span class="icon-bar"></span>
                     <span class="icon-bar"></span>
                 </button>
-                <a class="navbar-brand" href="index.html">JMeter Dashboard</a>
+                <a class="navbar-brand" 
href="index.html">${reportTitle!"Apache JMeter Dashboard"}</a>
             </div>
             <div class="navbar-default sidebar" role="navigation">
                 <div class="sidebar-nav navbar-collapse">

Modified: jmeter/trunk/bin/user.properties
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/bin/user.properties?rev=1739306&r1=1739305&r2=1739306&view=diff
==============================================================================
--- jmeter/trunk/bin/user.properties (original)
+++ jmeter/trunk/bin/user.properties Fri Apr 15 14:33:32 2016
@@ -73,6 +73,9 @@
 # If you want to debug reporting, uncomment this line
 #log_level.jmeter.report=DEBUG
 
+# Configure this property to change the report title
+#jmeter.reportgenerator.report_title=Apache JMeter Dashboard
+
 # Change this parameter if you want to change the granularity of over time 
graphs.
 #jmeter.reportgenerator.overall_granularity=60000
 

Modified: 
jmeter/trunk/src/core/org/apache/jmeter/report/config/ReportGeneratorConfiguration.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/config/ReportGeneratorConfiguration.java?rev=1739306&r1=1739305&r2=1739306&view=diff
==============================================================================
--- 
jmeter/trunk/src/core/org/apache/jmeter/report/config/ReportGeneratorConfiguration.java
 (original)
+++ 
jmeter/trunk/src/core/org/apache/jmeter/report/config/ReportGeneratorConfiguration.java
 Fri Apr 15 14:33:32 2016
@@ -67,6 +67,10 @@ public class ReportGeneratorConfiguratio
     private static final String REPORT_GENERATOR_KEY_SAMPLE_FILTER = 
REPORT_GENERATOR_KEY_PREFIX
             + KEY_DELIMITER + "sample_filter";
 
+    // report title
+    private static final String REPORT_GENERATOR_KEY_REPORT_TITLE = 
REPORT_GENERATOR_KEY_PREFIX
+            + KEY_DELIMITER + "report_title";
+
     private static final String LOAD_EXPORTER_FMT = "Load configuration for 
exporter \"%s\"";
     private static final String LOAD_GRAPH_FMT = "Load configuration for graph 
\"%s\"";
     private static final String INVALID_KEY_FMT = "Invalid property \"%s\", 
skip it.";
@@ -256,7 +260,7 @@ public class ReportGeneratorConfiguratio
         void initialize(String subConfId, T subConfiguration)
                 throws ConfigurationException;
     }
-
+    private String reportTitle;
     private String sampleFilter;
     private File tempDirectory;
     private long apdexSatisfiedThreshold;
@@ -623,6 +627,10 @@ public class ReportGeneratorConfiguratio
                 REPORT_GENERATOR_KEY_SAMPLE_FILTER, String.class);
         configuration.setSampleFilter(sampleFilter);
 
+        final String reportTitle = getOptionalProperty(props,
+                REPORT_GENERATOR_KEY_REPORT_TITLE, String.class);
+        configuration.setReportTitle(reportTitle);
+
         // Find graph identifiers and load a configuration for each
         final Map<String, GraphConfiguration> graphConfigurations = 
configuration
                 .getGraphConfigurations();
@@ -649,4 +657,18 @@ public class ReportGeneratorConfiguratio
 
         return configuration;
     }
+
+    /**
+     * @return the reportTitle
+     */
+    public String getReportTitle() {
+        return reportTitle;
+    }
+
+    /**
+     * @param reportTitle the reportTitle to set
+     */
+    public void setReportTitle(String reportTitle) {
+        this.reportTitle = reportTitle;
+    }
 }

Modified: 
jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/HtmlTemplateExporter.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/HtmlTemplateExporter.java?rev=1739306&r1=1739305&r2=1739306&view=diff
==============================================================================
--- 
jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/HtmlTemplateExporter.java
 (original)
+++ 
jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/HtmlTemplateExporter.java
 Fri Apr 15 14:33:32 2016
@@ -26,6 +26,7 @@ import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.Validate;
 import org.apache.jmeter.JMeter;
@@ -64,6 +65,7 @@ public class HtmlTemplateExporter extend
 
     private static final Logger LOG = LoggingManager.getLoggerForClass();
 
+    public static final String DATA_CTX_REPORT_TITLE = "reportTitle";
     public static final String DATA_CTX_TESTFILE = "testFile";
     public static final String DATA_CTX_BEGINDATE = "beginDate";
     public static final String DATA_CTX_ENDDATE = "endDate";
@@ -90,6 +92,12 @@ public class HtmlTemplateExporter extend
     // Default output folder name
     private static final String OUTPUT_DIR_NAME_DEFAULT = "report-output";
 
+    /**
+     * Adds to context the value surrounding it with quotes
+     * @param key Key
+     * @param value Value
+     * @param context {@link DataContext}
+     */
     private void addToContext(String key, Object value, DataContext context) {
         if (value instanceof String) {
             value = '"' + (String) value + '"';
@@ -450,6 +458,11 @@ public class HtmlTemplateExporter extend
         addToContext(DATA_CTX_TIMEZONE_OFFSET,
                 Integer.valueOf(timezone.getOffset(oldTimestamp)), 
dataContext);
 
+        // Add report title to the context
+        if(!StringUtils.isEmpty(configuration.getReportTitle())) {
+            dataContext.put(DATA_CTX_REPORT_TITLE, 
StringEscapeUtils.escapeHtml4(configuration.getReportTitle()));
+        }
+
         // Add the test file name to the context
         addToContext(DATA_CTX_TESTFILE, file.getName(), dataContext);
 

Modified: jmeter/trunk/xdocs/usermanual/generating-dashboard.xml
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/generating-dashboard.xml?rev=1739306&r1=1739305&r2=1739306&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/generating-dashboard.xml (original)
+++ jmeter/trunk/xdocs/usermanual/generating-dashboard.xml Fri Apr 15 14:33:32 
2016
@@ -410,6 +410,9 @@ jmeter.save.saveservice.timestamp_format
                     <p>You can copy the following configuration in your 
user.properties
                         file in order to test the report generator.</p>
                     <source>
+# Configure this property to change the report title
+#jmeter.reportgenerator.report_title=Apache JMeter Dashboard
+
 # Change this parameter if you want to change the granularity of over time 
graphs.
 jmeter.reportgenerator.overall_granularity=60000
 


Reply via email to