You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2015/12/30 18:08:01 UTC
svn commit: r1722381 -
/jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java
Author: fschumacher
Date: Wed Dec 30 17:08:00 2015
New Revision: 1722381
URL: http://svn.apache.org/viewvc?rev=1722381&view=rev
Log:
Extract a method to lessen the complexity of the method generate
Modified:
jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java
Modified: jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java?rev=1722381&r1=1722380&r2=1722381&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java Wed Dec 30 17:08:00 2015
@@ -216,43 +216,8 @@ public class ReportGenerator {
HashMap<GraphConfiguration, AbstractGraphConsumer> graphMap = new HashMap<>();
for (Map.Entry<String, GraphConfiguration> entryGraphCfg : graphConfigurations
.entrySet()) {
- String graphName = entryGraphCfg.getKey();
- GraphConfiguration graphConfiguration = entryGraphCfg.getValue();
-
- // Instantiate the class from the classname
- String className = graphConfiguration.getClassName();
- try {
- Class<?> clazz = Class.forName(className);
- Object obj = clazz.newInstance();
- AbstractGraphConsumer graph = (AbstractGraphConsumer) obj;
- graph.setName(graphName);
-
- // Set graph properties using reflection
- Method[] methods = clazz.getMethods();
- for (Map.Entry<String, String> entryProperty : graphConfiguration
- .getProperties().entrySet()) {
- String propertyName = entryProperty.getKey();
- String propertyValue = entryProperty.getValue();
- String setterName = getSetterName(propertyName);
-
- setProperty(className, obj, methods, propertyName,
- propertyValue, setterName);
- }
-
- // Choose which entry point to use to plug the graph
- AbstractSampleConsumer entryPoint = graphConfiguration
- .excludesControllers() ? excludeControllerFilter
- : nameFilter;
- entryPoint.addSampleConsumer(graph);
-
- // Add to the map
- graphMap.put(graphConfiguration, graph);
- } catch (ClassNotFoundException | IllegalAccessException
- | InstantiationException | ClassCastException ex) {
- String error = String.format(INVALID_CLASS_FMT, className);
- log.error(error, ex);
- throw new GenerationException(error, ex);
- }
+ addGraphConsumer(nameFilter, excludeControllerFilter, graphMap,
+ entryGraphCfg);
}
// Generate data
@@ -290,6 +255,50 @@ public class ReportGenerator {
}
+ private void addGraphConsumer(FilterConsumer nameFilter,
+ FilterConsumer excludeControllerFilter,
+ HashMap<GraphConfiguration, AbstractGraphConsumer> graphMap,
+ Map.Entry<String, GraphConfiguration> entryGraphCfg)
+ throws GenerationException {
+ String graphName = entryGraphCfg.getKey();
+ GraphConfiguration graphConfiguration = entryGraphCfg.getValue();
+
+ // Instantiate the class from the classname
+ String className = graphConfiguration.getClassName();
+ try {
+ Class<?> clazz = Class.forName(className);
+ Object obj = clazz.newInstance();
+ AbstractGraphConsumer graph = (AbstractGraphConsumer) obj;
+ graph.setName(graphName);
+
+ // Set graph properties using reflection
+ Method[] methods = clazz.getMethods();
+ for (Map.Entry<String, String> entryProperty : graphConfiguration
+ .getProperties().entrySet()) {
+ String propertyName = entryProperty.getKey();
+ String propertyValue = entryProperty.getValue();
+ String setterName = getSetterName(propertyName);
+
+ setProperty(className, obj, methods, propertyName,
+ propertyValue, setterName);
+ }
+
+ // Choose which entry point to use to plug the graph
+ AbstractSampleConsumer entryPoint = graphConfiguration
+ .excludesControllers() ? excludeControllerFilter
+ : nameFilter;
+ entryPoint.addSampleConsumer(graph);
+
+ // Add to the map
+ graphMap.put(graphConfiguration, graph);
+ } catch (ClassNotFoundException | IllegalAccessException
+ | InstantiationException | ClassCastException ex) {
+ String error = String.format(INVALID_CLASS_FMT, className);
+ log.error(error, ex);
+ throw new GenerationException(error, ex);
+ }
+ }
+
private void exportData(SampleContext sampleContext, String exporterName,
ExporterConfiguration exporterConfiguration)
throws GenerationException {