diff options
Diffstat (limited to 'qpid/java/perftests/visualisation-jfc/src')
43 files changed, 0 insertions, 3625 deletions
diff --git a/qpid/java/perftests/visualisation-jfc/src/main/assembly/qpid-perftests-visualisation-jfc-bin.xml b/qpid/java/perftests/visualisation-jfc/src/main/assembly/qpid-perftests-visualisation-jfc-bin.xml deleted file mode 100644 index f6bc7137f8..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/assembly/qpid-perftests-visualisation-jfc-bin.xml +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version='1.0'?> -<!-- - - 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. - ---> -<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> - <id>bin</id> - <formats> - <format>tar.gz</format> - </formats> - <baseDirectory>qpid-perftests-visualisation-jfc/${project.version}</baseDirectory> - <fileSets> - <fileSet> - <directory>${basedir}/src/main/assembly/</directory> - <outputDirectory>/</outputDirectory> - <includes> - <include>README.txt</include> - <include>NOTICE</include> - <include>LICENSE</include> - </includes> - <fileMode>0644</fileMode> - <directoryMode>0755</directoryMode> - </fileSet> - </fileSets> - <dependencySets> - <dependencySet> - <outputDirectory>/lib</outputDirectory> - <useProjectArtifact>true</useProjectArtifact> - </dependencySet> - </dependencySets> -</assembly> - diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartType.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartType.java deleted file mode 100644 index 5a77f22148..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartType.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.qpid.disttest.charting; - -public enum ChartType -{ - LINE, LINE3D, BAR, BAR3D, XYLINE, TIMELINE, STATISTICAL_BAR -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingException.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingException.java deleted file mode 100644 index 120a4dc750..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.qpid.disttest.charting; - -public class ChartingException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public ChartingException() - { - super(); - } - - public ChartingException(String message) - { - super(message); - } - - public ChartingException(Throwable cause) - { - super(cause); - } - - public ChartingException(String message, Throwable cause) - { - super(message, cause); - } - -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingUtil.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingUtil.java deleted file mode 100644 index 9401b77ab0..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingUtil.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * - * 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.qpid.disttest.charting; - -import java.io.File; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.qpid.disttest.ArgumentParser; -import org.apache.qpid.disttest.charting.chartbuilder.ChartBuilder; -import org.apache.qpid.disttest.charting.chartbuilder.ChartBuilderFactory; -import org.apache.qpid.disttest.charting.definition.ChartingDefinition; -import org.apache.qpid.disttest.charting.definition.ChartingDefinitionCreator; -import org.apache.qpid.disttest.charting.seriesbuilder.JdbcSeriesBuilder; -import org.apache.qpid.disttest.charting.seriesbuilder.JdbcUrlGenerator; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; -import org.apache.qpid.disttest.charting.writer.ChartWriter; -import org.jfree.chart.JFreeChart; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Draws charts for data drawn from CSV datasources using rules described in - * charting definitions (.chartdef) files. - * <p> - * The following arguments are understood: - * </p> - * <ol> - * <li>{@link #OUTPUT_DIR_PROP}</li> - * <li>{@link #CHART_DEFINITIONS_PROP}</li> - * <li>{@link #SUMMARY_TITLE_PROP}</li> - * <li>{@link #JDBC_DRIVER_NAME_PROP}</li> - * <li>{@link #JDBC_URL_PROP}</li> - * </ol> - * Default values are indicated by the similarly named constants in this class. - */ -public class ChartingUtil -{ - private static final Logger LOGGER = LoggerFactory.getLogger(ChartingUtil.class); - - /** directory in which to produce the PNGs */ - public static final String OUTPUT_DIR_PROP = "outputdir"; - public static final String OUTPUT_DIR_DEFAULT = "."; - - /** the path to the directory containing the chart definition files */ - public static final String CHART_DEFINITIONS_PROP = "chart-defs"; - public static final String CHART_DEFINITIONS_DEFAULT = "."; - - public static final String SUMMARY_TITLE_PROP = "summary-title"; - public static final String SUMMARY_TITLE_DEFAULT = "Performance Charts"; - - /** the class name of the JDBC driver to use for reading the chart data */ - public static final String JDBC_DRIVER_NAME_PROP = "jdbcDriverClass"; - public static final String JDBC_DRIVER_NAME_DEFAULT = JdbcUrlGenerator.DEFAULT_JDBC_DRIVER_NAME; - - /** the JDBC URL of the data to be charted */ - public static final String JDBC_URL_PROP = "jdbcUrl"; - public static final String JDBC_URL_DEFAULT = null; - - - private Map<String,String> _cliOptions = new HashMap<String, String>(); - - { - _cliOptions.put(OUTPUT_DIR_PROP, OUTPUT_DIR_DEFAULT); - _cliOptions.put(CHART_DEFINITIONS_PROP, CHART_DEFINITIONS_DEFAULT); - _cliOptions.put(SUMMARY_TITLE_PROP, SUMMARY_TITLE_DEFAULT); - _cliOptions.put(JDBC_DRIVER_NAME_PROP, JDBC_DRIVER_NAME_DEFAULT); - _cliOptions.put(JDBC_URL_PROP, JDBC_URL_DEFAULT); - } - - public static void main(String[] args) throws Exception - { - try - { - LOGGER.info("Starting charting"); - - ChartingUtil chartingUtil = new ChartingUtil(); - chartingUtil.parseArgumentsIntoConfig(args); - chartingUtil.produceAllCharts(); - } - finally - { - LOGGER.info("Charting complete"); - } - } - - private void produceAllCharts() - { - - final ChartWriter writer = new ChartWriter(); - writer.setOutputDirectory(new File(_cliOptions.get(OUTPUT_DIR_PROP))); - - SeriesBuilder seriesBuilder = new JdbcSeriesBuilder( - _cliOptions.get(JDBC_DRIVER_NAME_PROP), - _cliOptions.get(JDBC_URL_PROP)); - - for (ChartingDefinition chartingDefinition : loadChartDefinitions()) - { - try - { - ChartBuilder chartBuilder = ChartBuilderFactory.createChartBuilder( - chartingDefinition.getChartType(), - seriesBuilder); - - JFreeChart chart = chartBuilder.buildChart(chartingDefinition); - writer.writeChartToFileSystem(chart, chartingDefinition); - } - catch (Exception e) - { - LOGGER.error("Couldn't produce chart " + chartingDefinition, e); - } - } - - final String summaryChartTitle = _cliOptions.get(SUMMARY_TITLE_PROP); - writer.writeHtmlSummaryToFileSystem(summaryChartTitle); - } - - private List<ChartingDefinition> loadChartDefinitions() - { - final String chartingDefsDir = _cliOptions.get(CHART_DEFINITIONS_PROP); - - LOGGER.info("Chart chartdef directory/file: {}", chartingDefsDir); - - List<ChartingDefinition> definitions = loadChartDefinitions(chartingDefsDir); - - LOGGER.info("There are {} chart(s) to produce", definitions.size()); - return definitions; - } - - private List<ChartingDefinition> loadChartDefinitions(String chartingDefsDir) - { - ChartingDefinitionCreator chartingDefinitionLoader = new ChartingDefinitionCreator(); - return chartingDefinitionLoader.createFromFileOrDirectory(chartingDefsDir); - } - - private void parseArgumentsIntoConfig(String[] args) - { - ArgumentParser argumentParser = new ArgumentParser(); - argumentParser.parseArgumentsIntoConfig(_cliOptions, args); - } -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BarChart3DBuilder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BarChart3DBuilder.java deleted file mode 100644 index b10fd477ed..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BarChart3DBuilder.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - - -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; -import org.jfree.chart.ChartFactory; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.PlotOrientation; -import org.jfree.data.category.CategoryDataset; -import org.jfree.data.general.Dataset; - -public class BarChart3DBuilder extends CategoryDataSetBasedChartBuilder -{ - - public BarChart3DBuilder(SeriesBuilder seriesBuilder) - { - super(seriesBuilder); - } - - @Override - protected JFreeChart createCategoryChart(String title, String xAxisTitle, - String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation, - boolean showLegend, boolean showToolTips, boolean showUrls) - { - JFreeChart chart = ChartFactory.createBarChart3D(title, - xAxisTitle, - yAxisTitle, - (CategoryDataset)dataset, - plotOrientation, - showLegend, - showToolTips, - showUrls); - - return chart; - } - - -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BarChartBuilder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BarChartBuilder.java deleted file mode 100644 index 7705ef5d3a..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BarChartBuilder.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; -import org.jfree.chart.ChartFactory; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.PlotOrientation; -import org.jfree.data.category.CategoryDataset; -import org.jfree.data.general.Dataset; - -public class BarChartBuilder extends CategoryDataSetBasedChartBuilder -{ - - public BarChartBuilder(SeriesBuilder seriesBuilder) - { - super(seriesBuilder); - } - - @Override - protected JFreeChart createCategoryChart(String title, String xAxisTitle, - String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation, - boolean showLegend, boolean showToolTips, boolean showUrls) - { - JFreeChart chart = ChartFactory.createBarChart(title, - xAxisTitle, - yAxisTitle, - (CategoryDataset) dataset, - plotOrientation, - showLegend, - showToolTips, - showUrls); - return chart; - } - - -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java deleted file mode 100644 index 9cadf0ec3c..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilder.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - -import java.awt.Color; -import java.awt.GradientPaint; - -import org.apache.qpid.disttest.charting.definition.ChartingDefinition; -import org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; -import org.jfree.chart.ChartFactory; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.PlotOrientation; -import org.jfree.chart.title.ShortTextTitle; -import org.jfree.data.general.Dataset; - -public abstract class BaseChartBuilder implements ChartBuilder -{ - static final GradientPaint BLUE_GRADIENT = new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue); - - private SeriesPainter _seriesPainter = new SeriesPainter(); - - private final SeriesBuilder _seriesBuilder; - - protected BaseChartBuilder(SeriesBuilder seriesBuilder) - { - _seriesBuilder = seriesBuilder; - } - - @Override - public JFreeChart buildChart(ChartingDefinition chartingDefinition) - { - _seriesBuilder.setDatasetHolder(newDatasetHolder()); - Dataset dataset = _seriesBuilder.build(chartingDefinition.getSeriesDefinitions()); - - JFreeChart chart = createChart(chartingDefinition, dataset); - return chart; - } - - - /** - * return a holder of an empty dataset suitable for use with the chart type - * returned by {@link #createChartImpl(String, String, String, Dataset, PlotOrientation, boolean, boolean, boolean)}. - */ - protected abstract DatasetHolder newDatasetHolder(); - - /** - * Create a chart with the supplied parameters. - * - * For ease of implementation, the signature is intentionally similar - * to {@link ChartFactory}'s factory methods. - */ - protected abstract JFreeChart createChartImpl( - String title, String xAxisTitle, String yAxisTitle, - final Dataset dataset, - PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls); - - /** - * Create a {@link SeriesStrokeAndPaintApplier} that will be used to format a chart - */ - protected abstract SeriesStrokeAndPaintApplier newStrokeAndPaintApplier(); - - - private JFreeChart createChart(ChartingDefinition chartingDefinition, final Dataset dataset) - { - String title = chartingDefinition.getChartTitle(); - String xAxisTitle = chartingDefinition.getXAxisTitle(); - String yAxisTitle = chartingDefinition.getYAxisTitle(); - - final JFreeChart chart = createChartImpl( - title, xAxisTitle, yAxisTitle, - dataset, - PLOT_ORIENTATION, SHOW_LEGEND, SHOW_TOOL_TIPS, SHOW_URLS); - - addSubtitle(chart, chartingDefinition); - chart.setBackgroundPaint(BLUE_GRADIENT); - _seriesPainter.applySeriesAppearance(chart, chartingDefinition.getSeriesDefinitions(), newStrokeAndPaintApplier()); - - return chart; - } - - private void addSubtitle(JFreeChart chart, ChartingDefinition chartingDefinition) - { - if (chartingDefinition.getChartSubtitle() != null) - { - chart.addSubtitle(new ShortTextTitle(chartingDefinition.getChartSubtitle())); - } - } - - void setSeriesPainter(SeriesPainter seriesPainter) - { - _seriesPainter = seriesPainter; - } - -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryDataSetBasedChartBuilder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryDataSetBasedChartBuilder.java deleted file mode 100644 index 0d08fd8ad1..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryDataSetBasedChartBuilder.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - - -import org.apache.qpid.disttest.charting.definition.SeriesDefinition; -import org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.axis.CategoryLabelPositions; -import org.jfree.chart.plot.PlotOrientation; -import org.jfree.data.category.DefaultCategoryDataset; -import org.jfree.data.general.Dataset; - -public abstract class CategoryDataSetBasedChartBuilder extends BaseChartBuilder -{ - public CategoryDataSetBasedChartBuilder(SeriesBuilder seriesBuilder) - { - super(seriesBuilder); - } - - @Override - protected DatasetHolder newDatasetHolder() - { - return new DatasetHolder() - { - final private DefaultCategoryDataset _dataset = new DefaultCategoryDataset(); - - @Override - public void addDataPointToSeries(SeriesDefinition seriesDefinition, SeriesRow row) - { - String x = row.dimensionAsString(0); - double y = row.dimensionAsDouble(1); - _dataset.addValue(y, seriesDefinition.getSeriesLegend(), x); - } - - @Override - public void beginSeries(SeriesDefinition seriesDefinition) - { - // unused - } - - @Override - public void endSeries(SeriesDefinition seriesDefinition) - { - // unused - } - - @Override - public int getNumberOfDimensions() - { - return 2; - } - - @Override - public Dataset getPopulatedDataset() - { - return _dataset; - } - }; - } - - @Override - protected SeriesStrokeAndPaintApplier newStrokeAndPaintApplier() - { - return new CategoryStrokeAndPaintApplier(); - } - - @Override - protected final JFreeChart createChartImpl(String title, String xAxisTitle, String yAxisTitle, Dataset dataset, PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls) - { - JFreeChart chart = createCategoryChart(title, xAxisTitle, yAxisTitle, dataset, plotOrientation, showLegend, showToolTips, showUrls); - chart.getCategoryPlot().getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); - return chart; - } - - protected abstract JFreeChart createCategoryChart(String title, String xAxisTitle, String yAxisTitle, Dataset dataset, PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls); -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryStrokeAndPaintApplier.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryStrokeAndPaintApplier.java deleted file mode 100644 index cbf5cbe515..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/CategoryStrokeAndPaintApplier.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * 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.qpid.disttest.charting.chartbuilder; - -import java.awt.Color; -import java.awt.Stroke; - -import org.jfree.chart.JFreeChart; - -class CategoryStrokeAndPaintApplier implements SeriesStrokeAndPaintApplier -{ - @Override - public void setSeriesStroke(int seriesIndex, Stroke stroke, JFreeChart targetChart) - { - targetChart.getCategoryPlot().getRenderer().setSeriesStroke(seriesIndex, stroke); - } - - @Override - public void setSeriesPaint(int seriesIndex, Color colour, JFreeChart targetChart) - { - targetChart.getCategoryPlot().getRenderer().setSeriesPaint(seriesIndex, colour); - } -}
\ No newline at end of file diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilder.java deleted file mode 100644 index 425b83596f..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - -import org.apache.qpid.disttest.charting.definition.ChartingDefinition; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.PlotOrientation; - -public interface ChartBuilder -{ - public static final boolean SHOW_URLS = false; - public static final boolean SHOW_TOOL_TIPS = false; - public static final boolean SHOW_LEGEND = true; - public static final PlotOrientation PLOT_ORIENTATION = PlotOrientation.VERTICAL; - - public JFreeChart buildChart(ChartingDefinition chartingDefinition); -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactory.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactory.java deleted file mode 100644 index 63a0573676..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactory.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - -import org.apache.qpid.disttest.charting.ChartType; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; - -public class ChartBuilderFactory -{ - - public static ChartBuilder createChartBuilder(ChartType chartType, SeriesBuilder seriesBuilder) - { - switch (chartType) - { - case LINE: - return new LineChartBuilder(seriesBuilder); - case LINE3D: - return new LineChart3DBuilder(seriesBuilder); - case BAR: - return new BarChartBuilder(seriesBuilder); - case BAR3D: - return new BarChart3DBuilder(seriesBuilder); - case XYLINE: - return new XYLineChartBuilder(seriesBuilder); - case TIMELINE: - return new TimeSeriesLineChartBuilder(seriesBuilder); - case STATISTICAL_BAR: - return new StatisticalBarChartBuilder(seriesBuilder); - default: - throw new IllegalArgumentException("Unknown chart type " + chartType); - } - } - -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactory.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactory.java deleted file mode 100644 index 49d777c506..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactory.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - -import java.awt.Color; - -public class ColorFactory -{ - /** - * Converts a colour name known to the JDK into a {@link Color} instance. Additionally, - * if the work dark_ is prepended to the colour, a darker shade of the same colour is - * produced. - * - * @param colourName - * @return colour instance - */ - public static Color toColour(String colourName) - { - boolean darkVersion = false; - if (colourName.toLowerCase().startsWith("dark_")) - { - colourName = colourName.replaceFirst("(?i)dark_", ""); - darkVersion = true; - } - - Color colour = getColourFromStaticField(colourName); - if (darkVersion) - { - return colour.darker(); - } - else - { - return colour; - } - } - - private static Color getColourFromStaticField(String colourName) - { - try - { - return (Color) Color.class.getField(colourName.toLowerCase()).get(null); - } - catch (Exception e) - { - throw new RuntimeException("Could not find colour for " + colourName, e); - } - } - -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/LineChart3DBuilder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/LineChart3DBuilder.java deleted file mode 100644 index b92a25f5ac..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/LineChart3DBuilder.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; -import org.jfree.chart.ChartFactory; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.PlotOrientation; -import org.jfree.data.category.CategoryDataset; -import org.jfree.data.general.Dataset; - -public class LineChart3DBuilder extends CategoryDataSetBasedChartBuilder -{ - public LineChart3DBuilder(SeriesBuilder seriesBuilder) - { - super(seriesBuilder); - } - - @Override - protected JFreeChart createCategoryChart(String title, String xAxisTitle, - String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation, - boolean showLegend, boolean showToolTips, boolean showUrls) - { - JFreeChart chart = ChartFactory.createLineChart3D(title, - xAxisTitle, - yAxisTitle, - (CategoryDataset)dataset, - plotOrientation, - showLegend, - showToolTips, - showUrls); - return chart; - } - -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/LineChartBuilder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/LineChartBuilder.java deleted file mode 100644 index 3f5b18acda..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/LineChartBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; -import org.jfree.chart.ChartFactory; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.PlotOrientation; -import org.jfree.data.category.CategoryDataset; -import org.jfree.data.general.Dataset; - -public class LineChartBuilder extends CategoryDataSetBasedChartBuilder -{ - - public LineChartBuilder(SeriesBuilder seriesBuilder) - { - super(seriesBuilder); - } - - @Override - protected JFreeChart createCategoryChart(String title, String xAxisTitle, - String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation, - boolean showLegend, boolean showToolTips, boolean showUrls) - { - JFreeChart chart = ChartFactory.createLineChart(title, - xAxisTitle, - yAxisTitle, - (CategoryDataset)dataset, - plotOrientation, - showLegend, - showToolTips, - showUrls); - return chart; - } - -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesPainter.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesPainter.java deleted file mode 100644 index 854635dc87..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesPainter.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - -import java.awt.BasicStroke; -import java.util.List; - -import org.apache.qpid.disttest.charting.definition.SeriesDefinition; -import org.jfree.chart.JFreeChart; - -public class SeriesPainter -{ - public void applySeriesAppearance(JFreeChart chart, List<SeriesDefinition> seriesDefinitions, SeriesStrokeAndPaintApplier strokeAndPaintApplier) - { - for (int i = 0; i < seriesDefinitions.size(); i++) - { - SeriesDefinition seriesDefinition = seriesDefinitions.get(i); - if (seriesDefinition.getSeriesColourName() != null) - { - strokeAndPaintApplier.setSeriesPaint(i, ColorFactory.toColour(seriesDefinition.getSeriesColourName()), chart); - } - if (seriesDefinition.getStrokeWidth() != null) - { - // Negative width used to signify dashed - boolean dashed = seriesDefinition.getStrokeWidth() < 0; - float width = Math.abs(seriesDefinition.getStrokeWidth()); - BasicStroke stroke = buildStrokeOfWidth(width, dashed); - strokeAndPaintApplier.setSeriesStroke(i, stroke, chart); - } - } - } - - private BasicStroke buildStrokeOfWidth(float width, boolean dashed) - { - final BasicStroke stroke; - if (dashed) - { - stroke = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] {5.0f, 3.0f}, 0.0f); - } - else - { - stroke = new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); - } - return stroke; - } -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStrokeAndPaintApplier.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStrokeAndPaintApplier.java deleted file mode 100644 index 4d6c37a9f4..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesStrokeAndPaintApplier.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - -import java.awt.Color; -import java.awt.Stroke; - -import org.jfree.chart.JFreeChart; - -/** - * Applies the supplied stroke and color to a series in the target chart. - * Multiple implementations exist to because of the various chart types. - */ -public interface SeriesStrokeAndPaintApplier -{ - void setSeriesStroke(int seriesIndex, Stroke stroke, JFreeChart targetChart); - void setSeriesPaint(int seriesIndex, Color color, JFreeChart targetChart); -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/StatisticalBarChartBuilder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/StatisticalBarChartBuilder.java deleted file mode 100644 index c5ad2d7dad..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/StatisticalBarChartBuilder.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * - * 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.qpid.disttest.charting.chartbuilder; - -import java.awt.Font; - -import org.apache.qpid.disttest.charting.definition.SeriesDefinition; -import org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.axis.CategoryAxis; -import org.jfree.chart.axis.CategoryLabelPositions; -import org.jfree.chart.axis.NumberAxis; -import org.jfree.chart.axis.ValueAxis; -import org.jfree.chart.plot.CategoryPlot; -import org.jfree.chart.plot.PlotOrientation; -import org.jfree.chart.renderer.category.CategoryItemRenderer; -import org.jfree.chart.renderer.category.StatisticalBarRenderer; -import org.jfree.data.general.Dataset; -import org.jfree.data.statistics.DefaultStatisticalCategoryDataset; -import org.jfree.data.statistics.StatisticalCategoryDataset; - -public class StatisticalBarChartBuilder extends BaseChartBuilder -{ - public StatisticalBarChartBuilder(SeriesBuilder seriesBuilder) - { - super(seriesBuilder); - } - - @Override - protected DatasetHolder newDatasetHolder() - { - return new DatasetHolder() - { - private final DefaultStatisticalCategoryDataset _dataset = new DefaultStatisticalCategoryDataset(); - - @Override - public void addDataPointToSeries(SeriesDefinition seriesDefinition, SeriesRow row) - { - String x = row.dimensionAsString(0); - double mean = row.dimensionAsDouble(1); - double stdDev = row.dimensionAsDouble(2); - _dataset.add(mean, stdDev, seriesDefinition.getSeriesLegend(), x); - } - - @Override - public void beginSeries(SeriesDefinition seriesDefinition) - { - // unused - } - - @Override - public void endSeries(SeriesDefinition seriesDefinition) - { - // unused - } - - @Override - public int getNumberOfDimensions() - { - return 3; - } - - @Override - public Dataset getPopulatedDataset() - { - return _dataset; - } - }; - } - - @Override - protected SeriesStrokeAndPaintApplier newStrokeAndPaintApplier() - { - return new CategoryStrokeAndPaintApplier(); - } - - @Override - public JFreeChart createChartImpl(String title, String xAxisTitle, String yAxisTitle, final Dataset dataset, - PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls) - { - CategoryAxis xAxis = new CategoryAxis(xAxisTitle); - ValueAxis yAxis = new NumberAxis(yAxisTitle); - CategoryItemRenderer renderer = new StatisticalBarRenderer(); - - CategoryPlot plot = new CategoryPlot((StatisticalCategoryDataset) dataset, xAxis, yAxis, renderer); - - JFreeChart chart = new JFreeChart(title, new Font("Arial", Font.PLAIN, 10), plot, true); - - chart.getCategoryPlot().getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); - - return chart; - } - -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/TimeSeriesHolder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/TimeSeriesHolder.java deleted file mode 100644 index 803a098dfa..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/TimeSeriesHolder.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - -import java.util.Date; - -import org.apache.qpid.disttest.charting.definition.SeriesDefinition; -import org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow; -import org.jfree.data.general.Dataset; -import org.jfree.data.time.Millisecond; -import org.jfree.data.time.RegularTimePeriod; -import org.jfree.data.time.TimeSeries; -import org.jfree.data.time.TimeSeriesCollection; - -class TimeSeriesHolder implements DatasetHolder -{ - private final TimeSeriesCollection _timeSeriesCollection = new TimeSeriesCollection(); - private TimeSeries _timeSeries; - - @Override - public void beginSeries(SeriesDefinition seriesDefinition) - { - _timeSeries = new TimeSeries(seriesDefinition.getSeriesLegend()); - } - - @Override - public void addDataPointToSeries(SeriesDefinition seriesDefinition, SeriesRow row) - { - Date x = row.dimensionAsDate(0); - double y = row.dimensionAsDouble(1); - RegularTimePeriod jfreeChartDate = new Millisecond(x); - _timeSeries.add(jfreeChartDate, y); - } - - @Override - public void endSeries(SeriesDefinition seriesDefinition) - { - _timeSeriesCollection.addSeries(_timeSeries); - } - - @Override - public int getNumberOfDimensions() - { - return 2; - } - - @Override - public Dataset getPopulatedDataset() - { - return _timeSeriesCollection; - } -}
\ No newline at end of file diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/TimeSeriesLineChartBuilder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/TimeSeriesLineChartBuilder.java deleted file mode 100644 index 7249ae6332..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/TimeSeriesLineChartBuilder.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - -import org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; -import org.jfree.chart.ChartFactory; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.PlotOrientation; -import org.jfree.data.general.Dataset; -import org.jfree.data.xy.XYDataset; - -public class TimeSeriesLineChartBuilder extends XYDataSetBasedChartBuilder -{ - public TimeSeriesLineChartBuilder(SeriesBuilder seriesBuilder) - { - super(seriesBuilder); - } - - @Override - protected DatasetHolder newDatasetHolder() - { - return new TimeSeriesHolder(); - } - - @Override - public JFreeChart createChartImpl(String title, String xAxisTitle, - String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation, - boolean showLegend, boolean showToolTips, boolean showUrls) - { - JFreeChart chart = ChartFactory.createTimeSeriesChart( - title, - xAxisTitle, - yAxisTitle, - (XYDataset)dataset, - showLegend, - showToolTips, - showUrls); - - return chart; - } -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYDataSetBasedChartBuilder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYDataSetBasedChartBuilder.java deleted file mode 100644 index 575712f06c..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYDataSetBasedChartBuilder.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - -import java.awt.Color; -import java.awt.Stroke; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.qpid.disttest.charting.definition.SeriesDefinition; -import org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow; -import org.jfree.chart.JFreeChart; -import org.jfree.data.general.Dataset; -import org.jfree.data.xy.DefaultXYDataset; - - -public abstract class XYDataSetBasedChartBuilder extends BaseChartBuilder -{ - public XYDataSetBasedChartBuilder(SeriesBuilder seriesBuilder) - { - super(seriesBuilder); - } - - @Override - protected DatasetHolder newDatasetHolder() - { - return new DatasetHolder() - { - private final DefaultXYDataset _dataset = new DefaultXYDataset(); - private List<Double[]> _xyPairs = null; - - @Override - public void beginSeries(SeriesDefinition seriesDefinition) - { - _xyPairs = new ArrayList<Double[]>(); - } - - @Override - public void addDataPointToSeries(SeriesDefinition seriesDefinition, SeriesRow row) - { - double x = row.dimensionAsDouble(0); - double y = row.dimensionAsDouble(1); - _xyPairs.add(new Double[] {x, y}); - } - - @Override - public void endSeries(SeriesDefinition seriesDefinition) - { - double[][] seriesData = listToSeriesDataArray(); - _dataset.addSeries(seriesDefinition.getSeriesLegend(), seriesData); - } - - @Override - public int getNumberOfDimensions() - { - return 2; - } - - private double[][] listToSeriesDataArray() - { - double[][] seriesData = new double[2][_xyPairs.size()]; - int i = 0; - for (Iterator<Double[]> iterator = _xyPairs.iterator(); iterator.hasNext();) - { - Double[] xyPair = iterator.next(); - seriesData[0][i] = xyPair[0]; - seriesData[1][i] = xyPair[1]; - i++; - } - return seriesData; - } - - @Override - public Dataset getPopulatedDataset() - { - return _dataset; - } - }; - } - - @Override - protected SeriesStrokeAndPaintApplier newStrokeAndPaintApplier() - { - return new SeriesStrokeAndPaintApplier() - { - @Override - public void setSeriesStroke(int seriesIndex, Stroke stroke, JFreeChart targetChart) - { - targetChart.getXYPlot().getRenderer().setSeriesStroke(seriesIndex, stroke); - } - - @Override - public void setSeriesPaint(int seriesIndex, Color colour, JFreeChart targetChart) - { - targetChart.getXYPlot().getRenderer().setSeriesPaint(seriesIndex, colour); - } - }; - } -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYLineChartBuilder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYLineChartBuilder.java deleted file mode 100644 index 48b02a7c60..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/XYLineChartBuilder.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; -import org.jfree.chart.ChartFactory; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.PlotOrientation; -import org.jfree.data.general.Dataset; -import org.jfree.data.xy.XYDataset; - -public class XYLineChartBuilder extends XYDataSetBasedChartBuilder -{ - public XYLineChartBuilder(SeriesBuilder seriesBuilder) - { - super(seriesBuilder); - } - - @Override - public JFreeChart createChartImpl(String title, String xAxisTitle, - String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation, - boolean showLegend, boolean showToolTips, boolean showUrls) - { - JFreeChart chart = ChartFactory.createXYLineChart(title, - xAxisTitle, - yAxisTitle, - (XYDataset)dataset, - plotOrientation, - showLegend, - showToolTips, - showUrls); - return chart; - } -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinition.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinition.java deleted file mode 100644 index 5030c42e89..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinition.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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.qpid.disttest.charting.definition; - -import java.util.Collections; -import java.util.List; - -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.qpid.disttest.charting.ChartType; - -public class ChartingDefinition -{ - private final String _chartStemName; - private final ChartType _chartType; - private final String _chartTitle; - private final String _chartSubtitle; - private final String _chartDescription; - private final String _xaxisTitle; - private final String _yaxisTitle; - private final List<SeriesDefinition> _seriesDefinitions; - - - public ChartingDefinition(final String chartStemName, - final ChartType chartType, - final String chartTitle, - final String chartSubtitle, - final String chartDescription, - final String xaxisTitle, final String yaxisTitle, List<SeriesDefinition> seriesDefinitions) - { - _chartStemName = chartStemName; - _chartType = chartType; - _chartTitle = chartTitle; - _chartSubtitle = chartSubtitle; - _chartDescription = chartDescription; - _xaxisTitle = xaxisTitle; - _yaxisTitle = yaxisTitle; - _seriesDefinitions = seriesDefinitions; - } - - public String getChartStemName() - { - return _chartStemName; - } - - public String getChartTitle() - { - return _chartTitle; - } - - public String getChartSubtitle() - { - return _chartSubtitle; - } - - public String getChartDescription() - { - return _chartDescription; - } - - public String getXAxisTitle() - { - return _xaxisTitle; - } - - - public String getYAxisTitle() - { - return _yaxisTitle; - } - - public ChartType getChartType() - { - return _chartType; - } - - public List<SeriesDefinition> getSeriesDefinitions() - { - return Collections.unmodifiableList(_seriesDefinitions); - } - - @Override - public String toString() - { - return new ToStringBuilder(this).append("chartTitle", _chartTitle).toString(); - } - -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreator.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreator.java deleted file mode 100644 index e0f43cb34a..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreator.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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.qpid.disttest.charting.definition; - -import static org.apache.commons.lang.text.StrSubstitutor.replaceSystemProperties; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileFilter; -import java.io.FileReader; -import java.io.IOException; -import java.io.Reader; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import org.apache.qpid.disttest.charting.ChartType; -import org.apache.qpid.disttest.charting.ChartingException; - -public class ChartingDefinitionCreator -{ - public static final String CHARTDEF_FILE_EXTENSION = ".chartdef"; - - public static final String CHART_TYPE_KEY = "chartType"; - public static final String CHART_TITLE_KEY = "chartTitle"; - public static final String CHART_SUBTITLE_KEY = "chartSubtitle"; - public static final String CHART_DESCRIPTION_KEY = "chartDescription"; - public static final String XAXIS_TITLE_KEY = "xAxisTitle"; - public static final String YAXIS_TITLE_KEY = "yAxisTitle"; - - private SeriesDefinitionCreator _seriesDefinitionCreator = new SeriesDefinitionCreator(); - - public List<ChartingDefinition> createFromFileOrDirectory(String chartingDefinitionFileOrDirectory) - { - List<ChartingDefinition> definitions = new ArrayList<ChartingDefinition>(); - - File fileOrDirectory = new File(chartingDefinitionFileOrDirectory); - if (fileOrDirectory.isDirectory()) - { - File[] matchingFiles = fileOrDirectory.listFiles(new CHARTDEF_FILE_FILTER()); - - for (File file : matchingFiles) - { - final ChartingDefinition chartDefinition = createChartDefinition(file); - definitions.add(chartDefinition); - } - } - else - { - final ChartingDefinition chartDefinition = createChartDefinition(fileOrDirectory); - definitions.add(chartDefinition); - } - - return definitions; - } - - private ChartingDefinition createChartDefinition(File file) - { - Reader reader = null; - try - { - reader = new BufferedReader(new FileReader(file)); - Properties props = new Properties(); - props.load(reader); - - final String chartStemName = getStemNameFrom(file); - - final ChartType chartType = ChartType.valueOf(replaceSystemProperties(props.getProperty(CHART_TYPE_KEY))); - final String chartTitle = replaceSystemProperties(props.getProperty(CHART_TITLE_KEY)); - final String chartSubtitle = replaceSystemProperties(props.getProperty(CHART_SUBTITLE_KEY)); - final String chartDescription = replaceSystemProperties(props.getProperty(CHART_DESCRIPTION_KEY)); - final String xAxisTitle = replaceSystemProperties(props.getProperty(XAXIS_TITLE_KEY)); - final String yAxisTitle = replaceSystemProperties(props.getProperty(YAXIS_TITLE_KEY)); - - final List<SeriesDefinition> seriesDefinitions = createSeriesDefinitions(props); - - final ChartingDefinition chartDefinition = new ChartingDefinition(chartStemName, - chartType, - chartTitle, - chartSubtitle, - chartDescription, - xAxisTitle, yAxisTitle, seriesDefinitions); - return chartDefinition; - } - catch (IOException e) - { - throw new ChartingException("Unable to open file " + file, e); - } - finally - { - if (reader != null) - { - try - { - reader.close(); - } - catch (IOException e) - { - throw new ChartingException(e); - } - } - } - - } - - private String getStemNameFrom(File file) - { - final String nameWithExtension = file.getName(); - final String nameWithoutExtensionPart = nameWithExtension.replaceAll("\\.[^\\.]*$", ""); - return nameWithoutExtensionPart; - } - - private List<SeriesDefinition> createSeriesDefinitions(Properties props) - { - return _seriesDefinitionCreator.createFromProperties(props); - } - - private final class CHARTDEF_FILE_FILTER implements FileFilter - { - @Override - public boolean accept(File pathname) - { - return pathname.isFile() && pathname.getName().endsWith(CHARTDEF_FILE_EXTENSION); - } - } -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinition.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinition.java deleted file mode 100644 index d89ff855e2..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinition.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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.qpid.disttest.charting.definition; - -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -public class SeriesDefinition -{ - private final String _seriesStatement; - private final String _seriesLegend; - private final String _seriesDirectory; - private final String _seriesColourName; - private final Integer _seriesStrokeWidth; - - public SeriesDefinition(String seriesStatement, String seriesLegend, String seriesDirectory, String seriesColourName, Integer seriesStrokeWidth) - { - _seriesStatement = seriesStatement; - _seriesLegend = seriesLegend; - _seriesDirectory = seriesDirectory; - _seriesColourName = seriesColourName; - _seriesStrokeWidth = seriesStrokeWidth; - } - - public String getSeriesStatement() - { - return _seriesStatement; - } - - public String getSeriesLegend() - { - return _seriesLegend; - } - - public String getSeriesDirectory() - { - return _seriesDirectory; - } - - public String getSeriesColourName() - { - return _seriesColourName; - } - - public Integer getStrokeWidth() - { - return _seriesStrokeWidth; - } - - @Override - public String toString() - { - return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) - .append("seriesLegend", _seriesLegend) - .append("seriesStatement", _seriesStatement) - .append("seriesDirectory", _seriesDirectory).toString(); - } -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreator.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreator.java deleted file mode 100644 index e7d828bdcc..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreator.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.qpid.disttest.charting.definition; - -import static org.apache.commons.lang.text.StrSubstitutor.replaceSystemProperties; - -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -public class SeriesDefinitionCreator -{ - public static final String SERIES_STATEMENT_KEY_FORMAT = "series.%d.statement"; - public static final String SERIES_LEGEND_KEY_FORMAT = "series.%d.legend"; - public static final String SERIES_DIRECTORY_KEY_FORMAT = "series.%d.dir"; - public static final String SERIES_COLOUR_NAME_FORMAT = "series.%d.colourName"; - public static final String SERIES_STROKE_WIDTH_FORMAT = "series.%d.strokeWidth"; - - public List<SeriesDefinition> createFromProperties(Properties properties) - { - final List<SeriesDefinition> seriesDefinitions = new ArrayList<SeriesDefinition>(); - - int index = 1; - boolean moreSeriesDefinitions = true; - while(moreSeriesDefinitions) - { - String seriesStatement = replaceSystemProperties(properties.getProperty(String.format(SERIES_STATEMENT_KEY_FORMAT, index))); - String seriesLegend = replaceSystemProperties(properties.getProperty(String.format(SERIES_LEGEND_KEY_FORMAT, index))); - String seriesDir = replaceSystemProperties(properties.getProperty(String.format(SERIES_DIRECTORY_KEY_FORMAT, index))); - String seriesColourName = replaceSystemProperties(properties.getProperty(String.format(SERIES_COLOUR_NAME_FORMAT, index))); - Integer seriesStrokeWidth = properties.getProperty(String.format(SERIES_STROKE_WIDTH_FORMAT, index)) == null - ? null : Integer.parseInt(properties.getProperty(String.format(SERIES_STROKE_WIDTH_FORMAT, index))); - - if (seriesStatement != null) - { - final SeriesDefinition seriesDefinition = new SeriesDefinition(seriesStatement, seriesLegend, seriesDir, seriesColourName, seriesStrokeWidth); - seriesDefinitions.add(seriesDefinition); - } - else - { - moreSeriesDefinitions = false; - } - index++; - } - return seriesDefinitions; - } - -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/DatasetHolder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/DatasetHolder.java deleted file mode 100644 index 14fd50facc..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/DatasetHolder.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.qpid.disttest.charting.seriesbuilder; - -import org.apache.qpid.disttest.charting.definition.SeriesDefinition; -import org.jfree.data.general.Dataset; - -/** - * Accepts data in the form of {@link SeriesDefinition}s and {@link SeriesRow}s, - * and returns it as a {@link Dataset} for use by a JFreeChart chart. - */ -public interface DatasetHolder -{ - int getNumberOfDimensions(); - void beginSeries(SeriesDefinition seriesDefinition); - void addDataPointToSeries(SeriesDefinition seriesDefinition, SeriesRow row); - void endSeries(SeriesDefinition seriesDefinition); - - Dataset getPopulatedDataset(); -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcSeriesBuilder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcSeriesBuilder.java deleted file mode 100644 index 180aa54c6d..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcSeriesBuilder.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * 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.qpid.disttest.charting.seriesbuilder; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.Iterator; -import java.util.List; - -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; -import org.apache.qpid.disttest.charting.ChartingException; -import org.apache.qpid.disttest.charting.definition.SeriesDefinition; -import org.jfree.data.general.Dataset; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A {@link SeriesBuilder} that uses JDBC to read series data. - * The actual JDBC URL used is determined by my {@link JdbcUrlGenerator}. - */ -public class JdbcSeriesBuilder implements SeriesBuilder -{ - private static final Logger LOGGER = LoggerFactory.getLogger(JdbcSeriesBuilder.class); - - private DatasetHolder _datasetHolder; - - private final JdbcUrlGenerator _jdbcUrlGenerator; - - /** - * @param providedJdbcUrl the JDBC URL. Provide null if the value should be - * inferred by {@link #_jdbcUrlGenerator}. - */ - public JdbcSeriesBuilder(String jdbcDriverClass, String providedJdbcUrl) - { - registerDriver(jdbcDriverClass); - _jdbcUrlGenerator = new JdbcUrlGenerator(providedJdbcUrl); - LOGGER.info("Created: " + this); - } - - @Override - public void setDatasetHolder(DatasetHolder callback) - { - _datasetHolder = callback; - } - - @Override - public Dataset build(List<SeriesDefinition> seriesDefinitions) - { - for (Iterator<SeriesDefinition> iterator = seriesDefinitions.iterator(); iterator.hasNext();) - { - SeriesDefinition series = iterator.next(); - buildDataSetForSingleSeries(series); - } - return _datasetHolder.getPopulatedDataset(); - } - - private void buildDataSetForSingleSeries(SeriesDefinition seriesDefinition) - { - Connection conn = null; - Statement stmt = null; - try - { - String jdbcUrl = _jdbcUrlGenerator.getJdbcUrl(seriesDefinition); - conn = DriverManager.getConnection(jdbcUrl); - - final String seriesStatement = seriesDefinition.getSeriesStatement(); - - stmt = conn.createStatement(); - ResultSet results = stmt.executeQuery(seriesStatement); - int columnCount = results.getMetaData().getColumnCount(); - _datasetHolder.beginSeries(seriesDefinition); - while (results.next()) - { - Object[] row = new Object[columnCount]; - for (int i = 0; i < row.length; i++) - { - row[i] = results.getObject(i+1); - } - - SeriesRow seriesRow = SeriesRow.createValidSeriesRow(_datasetHolder.getNumberOfDimensions(), row); - _datasetHolder.addDataPointToSeries(seriesDefinition, seriesRow); - } - _datasetHolder.endSeries(seriesDefinition); - } - catch (SQLException e) - { - throw new ChartingException("Failed to create chart dataset", e); - } - finally - { - if (stmt != null) - { - try - { - stmt.close(); - } - catch (SQLException e) - { - throw new RuntimeException("Failed to close statement", e); - } - } - if (conn != null) - { - try - { - conn.close(); - } - catch (SQLException e) - { - throw new RuntimeException("Failed to close connection", e); - } - } - } - } - - private void registerDriver(String driverClassName) throws ExceptionInInitializerError - { - try - { - Class.forName(driverClassName); - LOGGER.info("Loaded JDBC driver class " + driverClassName); - } - catch (ClassNotFoundException e) - { - throw new RuntimeException("Could not load JDBC driver " + driverClassName, e); - } - } - - @Override - public String toString() - { - return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) - .append("jdbcUrlGenerator", _jdbcUrlGenerator) - .toString(); - } -} diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcUrlGenerator.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcUrlGenerator.java deleted file mode 100644 index 77f367b0f1..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcUrlGenerator.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.qpid.disttest.charting.seriesbuilder; - -import static org.apache.commons.lang.StringUtils.isBlank; -import static org.apache.commons.lang.StringUtils.isNotBlank; - -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; -import org.apache.qpid.disttest.charting.definition.SeriesDefinition; - -public class JdbcUrlGenerator -{ - private String _providedJdbdUrl; - - public static final String DEFAULT_JDBC_DRIVER_NAME = "org.relique.jdbc.csv.CsvDriver"; - - /** - * Used to create the JDBC URL if one has not been passed in. - */ - private static final String CSV_JDBC_URL_BASE = "jdbc:relique:csv:"; - - /** - * @param providedJdbcUrl the JDBC URL. Provide null if the value should be - * inferred. - */ - public JdbcUrlGenerator(String providedJdbcUrl) - { - _providedJdbdUrl = providedJdbcUrl; - } - - /** - * Returns either the provided value ({@link #_providedJdbdUrl}) - * or a CSV JDBC URL pointing at {@link SeriesDefinition#getSeriesDirectory()} value. - */ - public String getJdbcUrl(SeriesDefinition seriesDefinition) - { - String seriesDir = seriesDefinition.getSeriesDirectory(); - - if(_providedJdbdUrl == null) - { - if(isBlank(seriesDir)) - { - throw new IllegalArgumentException("Neither a series directory nor a JDBC url have been specified. Series definition: " + seriesDefinition); - } - return CSV_JDBC_URL_BASE + seriesDir; - } - else - { - if(isNotBlank(seriesDir)) - { - throw new IllegalArgumentException("Both a series directory '" + seriesDir + "' and a JDBC url have been specified. Series definition: " + seriesDefinition); - } - return _providedJdbdUrl; - } - } - - @Override - public String toString() - { - return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) - .append("providedJdbdUrl", _providedJdbdUrl) - .toString(); - } -}
\ No newline at end of file diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesBuilder.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesBuilder.java deleted file mode 100644 index a865c838c6..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesBuilder.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.qpid.disttest.charting.seriesbuilder; - -import java.util.List; - -import org.apache.qpid.disttest.charting.definition.SeriesDefinition; -import org.jfree.data.general.Dataset; - -public interface SeriesBuilder -{ - /** - * Uses the supplied {@link SeriesDefinition}s to read the series data - * and pass it to the dataset holder set up in {@link #setDatasetHolder(DatasetHolder)}. - * - * @return the populated dataset - */ - Dataset build(List<SeriesDefinition> seriesDefinitions); - - /** - * Stores the supplied dataset holder so it can be populated in {@link #build(List)}. - */ - void setDatasetHolder(DatasetHolder datasetHolder); -}
\ No newline at end of file diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesRow.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesRow.java deleted file mode 100644 index 9c16866939..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesRow.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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.qpid.disttest.charting.seriesbuilder; - -import java.util.Arrays; -import java.util.Date; - -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; - -/** - * A data point in a chart. Thinly wraps an array to provide a convenient place to validate the number of dimensions, - * and to access dimensions in a typesafe manner. - */ -public class SeriesRow -{ - private final Object[] _dimensions; - - public static SeriesRow createValidSeriesRow(int expectedNumberOfDimensions, Object[] dimensions) - { - int actualNumberOfDimensions = dimensions.length; - if(expectedNumberOfDimensions != actualNumberOfDimensions) - { - throw new IllegalArgumentException("Expected " + expectedNumberOfDimensions - + " dimensions but found " + actualNumberOfDimensions - + " in: " + Arrays.asList(dimensions)); - } - return new SeriesRow(dimensions); - } - - public SeriesRow(Object... dimensions) - { - _dimensions = dimensions; - } - - public Object dimension(int dimension) - { - return _dimensions[dimension]; - } - - public String dimensionAsString(int dimension) - { - return String.valueOf(dimension(dimension)); - } - - public double dimensionAsDouble(int dimension) - { - return Double.parseDouble(dimensionAsString(dimension)); - } - - public Date dimensionAsDate(int dimension) - { - return (Date) dimension(dimension); - } - - @Override - public int hashCode() - { - return new HashCodeBuilder().append(_dimensions).toHashCode(); - } - - @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - if (obj == this) - { - return true; - } - if (obj.getClass() != getClass()) - { - return false; - } - SeriesRow rhs = (SeriesRow) obj; - return new EqualsBuilder().append(_dimensions, rhs._dimensions).isEquals(); - } - - -}
\ No newline at end of file diff --git a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/writer/ChartWriter.java b/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/writer/ChartWriter.java deleted file mode 100644 index 341f01ccd1..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/writer/ChartWriter.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * 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.qpid.disttest.charting.writer; - -import java.io.BufferedOutputStream; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.OutputStream; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.apache.qpid.disttest.charting.ChartingException; -import org.apache.qpid.disttest.charting.definition.ChartingDefinition; -import org.jfree.chart.ChartUtilities; -import org.jfree.chart.JFreeChart; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ChartWriter -{ - private static final Logger LOGGER = LoggerFactory.getLogger(ChartWriter.class); - - static final String SUMMARY_FILE_NAME = "chart-summary.html"; - - private File _chartDirectory = new File("."); - private SortedMap<File,ChartingDefinition> _chartFilesToChartDef = new TreeMap<File, ChartingDefinition>(); - - public void writeChartToFileSystem(JFreeChart chart, ChartingDefinition chartDef) - { - OutputStream pngOutputStream = null; - try - { - File pngFile = new File(_chartDirectory, chartDef.getChartStemName() + ".png"); - pngOutputStream = new BufferedOutputStream(new FileOutputStream(pngFile)); - ChartUtilities.writeChartAsPNG(pngOutputStream, chart, 600, 400, true, 0); - pngOutputStream.close(); - - _chartFilesToChartDef.put(pngFile, chartDef); - - LOGGER.info("Written {} chart", pngFile); - } - catch (IOException e) - { - throw new ChartingException("Failed to create chart", e); - } - finally - { - if (pngOutputStream != null) - { - try - { - pngOutputStream.close(); - } - catch (IOException e) - { - throw new ChartingException("Failed to create chart", e); - } - } - } - } - - public void writeHtmlSummaryToFileSystem(String summaryPageTitle) - { - if(_chartFilesToChartDef.size() < 2) - { - LOGGER.info("Only {} chart image(s) have been written so no HTML summary file will be produced", _chartFilesToChartDef.size()); - return; - } - - String htmlHeader = String.format( - "<html>\n" + - " <head>\n" + - " <title>%s</title>\n" + - " <style type='text/css'>figure { float: left; display: table; width: 87px;}</style>\n" + - " </head>\n" + - " <body>\n", summaryPageTitle); - - String htmlFooter = - " </body>\n" + - "</html>"; - - BufferedWriter writer = null; - try - { - File summaryFile = new File(_chartDirectory, SUMMARY_FILE_NAME); - LOGGER.debug("About to produce HTML summary file " + summaryFile.getAbsolutePath() + " from charts " + _chartFilesToChartDef); - - writer = new BufferedWriter(new FileWriter(summaryFile)); - writer.write(htmlHeader); - - writer.write(" <ul>\n"); - for (File chartFile : _chartFilesToChartDef.keySet()) - { - writer.write(" <li><a href='#"+ chartFile.getName() +"'>" + chartFile.getName() + "</a></li>\n"); - } - writer.write(" </ul>\n"); - - for (File chartFile : _chartFilesToChartDef.keySet()) - { - ChartingDefinition def = _chartFilesToChartDef.get(chartFile); - writer.write(" <figure>\n"); - writer.write(" <a name='" + chartFile.getName() + "'/>\n"); - writer.write(" <img src='" + chartFile.getName() + "'/>\n"); - if (def.getChartDescription() != null) - { - writer.write(" <figcaption>" + def.getChartDescription() + "</figcaption>\n"); - } - writer.write(" </figure>\n"); - } - writer.write(htmlFooter); - writer.close(); - } - catch (Exception e) - { - throw new ChartingException("Failed to create HTML summary file", e); - } - finally - { - if(writer != null) - { - try - { - writer.close(); - } - catch(IOException e) - { - throw new ChartingException("Failed to create HTML summary file", e); - } - } - } - } - - public void setOutputDirectory(final File chartDirectory) - { - _chartDirectory = chartDirectory; - LOGGER.info("Set chart directory: {}", chartDirectory); - } -} diff --git a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilderTest.java b/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilderTest.java deleted file mode 100644 index c8a98aafa0..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/BaseChartBuilderTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.List; - -import org.apache.qpid.disttest.charting.definition.ChartingDefinition; -import org.apache.qpid.disttest.charting.definition.SeriesDefinition; -import org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; -import org.apache.qpid.test.utils.QpidTestCase; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.CategoryPlot; -import org.jfree.chart.plot.Plot; -import org.jfree.chart.plot.PlotOrientation; -import org.jfree.chart.title.TextTitle; -import org.jfree.data.general.Dataset; - -public class BaseChartBuilderTest extends QpidTestCase -{ - private static final String CHART_TITLE = "CHART_TITLE"; - private static final String CHART_SUB_TITLE = "CHART_SUB_TITLE"; - private static final String X_TITLE = "X_TITLE"; - private static final String Y_TITLE = "Y_TITLE"; - - @SuppressWarnings("unchecked") - private List<SeriesDefinition> _seriesDefinitions = mock(List.class); - - private ChartingDefinition _chartingDefinition = mock(ChartingDefinition.class); - private SeriesStrokeAndPaintApplier _strokeAndPaintApplier = mock(SeriesStrokeAndPaintApplier.class); - private DatasetHolder _datasetHolder = mock(DatasetHolder.class); - private SeriesPainter _seriesPainter = mock(SeriesPainter.class); - - private SeriesBuilder _seriesBuilder = mock(SeriesBuilder.class); - - private JFreeChart _jFreeChart; - - @Override - protected void setUp() throws Exception - { - super.setUp(); - - Plot plot = new CategoryPlot(); - _jFreeChart = new JFreeChart(plot); - - when(_chartingDefinition.getChartTitle()).thenReturn(CHART_TITLE); - when(_chartingDefinition.getChartSubtitle()).thenReturn(CHART_SUB_TITLE); - when(_chartingDefinition.getXAxisTitle()).thenReturn(X_TITLE); - when(_chartingDefinition.getYAxisTitle()).thenReturn(Y_TITLE); - when(_chartingDefinition.getSeriesDefinitions()).thenReturn(_seriesDefinitions ); - } - - public void testBuildChart() - { - BaseChartBuilder chartBuilder = new ChartBuilder(_seriesBuilder, _strokeAndPaintApplier, _datasetHolder) - { - @Override - protected JFreeChart createChartImpl(String title, String xAxisTitle, String yAxisTitle, Dataset dataset, PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls) - { - assertEquals(CHART_TITLE, title); - assertEquals(X_TITLE, xAxisTitle); - assertEquals(Y_TITLE, yAxisTitle); - - return _jFreeChart; - } - }; - - JFreeChart chart = chartBuilder.buildChart(_chartingDefinition); - - assertEquals(BaseChartBuilder.BLUE_GRADIENT, chart.getBackgroundPaint()); - assertEquals("The *second* subtitle of the generated chart should have the text from the chart definition", - CHART_SUB_TITLE, ((TextTitle)chart.getSubtitle(1)).getText()); - verify(_seriesPainter).applySeriesAppearance(_jFreeChart, _seriesDefinitions, _strokeAndPaintApplier); - } - - /** - * Extends BaseChartBuilder to allow us to plug in in mock dependencies - */ - private abstract class ChartBuilder extends BaseChartBuilder - { - private SeriesStrokeAndPaintApplier _seriesStrokeAndPaintApplier; - private DatasetHolder _datasetHolder; - - private ChartBuilder(SeriesBuilder seriesBuilder, SeriesStrokeAndPaintApplier seriesStrokeAndPaintApplier, DatasetHolder datasetHolder) - { - super(seriesBuilder); - _seriesStrokeAndPaintApplier = seriesStrokeAndPaintApplier; - _datasetHolder = datasetHolder; - setSeriesPainter(_seriesPainter); - } - - @Override - protected SeriesStrokeAndPaintApplier newStrokeAndPaintApplier() - { - return _seriesStrokeAndPaintApplier; - } - - @Override - protected DatasetHolder newDatasetHolder() - { - return _datasetHolder; - } - } -} diff --git a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactoryTest.java b/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactoryTest.java deleted file mode 100644 index 14f81566a6..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactoryTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - -import static org.mockito.Mockito.mock; - -import org.apache.qpid.disttest.charting.ChartType; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; -import org.apache.qpid.test.utils.QpidTestCase; - -public class ChartBuilderFactoryTest extends QpidTestCase -{ - private SeriesBuilder _seriesBuilder = mock(SeriesBuilder.class); - - public void testLineChart() - { - ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.LINE, _seriesBuilder); - assertTrue(builder instanceof LineChartBuilder); - } - - public void testLineChart3D() - { - ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.LINE3D, _seriesBuilder); - assertTrue(builder instanceof LineChart3DBuilder); - } - - public void testBarChart() - { - ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.BAR, _seriesBuilder); - assertTrue(builder instanceof BarChartBuilder); - } - - public void testBarChart3D() - { - ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.BAR3D, _seriesBuilder); - assertTrue(builder instanceof BarChart3DBuilder); - } - - public void testXYLineChart() - { - ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.XYLINE, _seriesBuilder); - assertTrue(builder instanceof XYLineChartBuilder); - } - - public void testTimeSeriesLineChart() - { - ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.TIMELINE, _seriesBuilder); - assertTrue(builder instanceof TimeSeriesLineChartBuilder); - } -} diff --git a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ChartProductionTest.java b/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ChartProductionTest.java deleted file mode 100644 index 08d39fd0ce..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ChartProductionTest.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.File; -import java.util.Collections; -import java.util.Date; -import java.util.Iterator; -import java.util.List; - -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.XYPlot; -import org.jfree.chart.title.ShortTextTitle; -import org.jfree.data.general.Dataset; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.apache.qpid.disttest.charting.ChartType; -import org.apache.qpid.disttest.charting.definition.ChartingDefinition; -import org.apache.qpid.disttest.charting.definition.SeriesDefinition; -import org.apache.qpid.disttest.charting.seriesbuilder.DatasetHolder; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesBuilder; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow; -import org.apache.qpid.disttest.charting.writer.ChartWriter; -import org.apache.qpid.test.utils.QpidTestCase; -import org.apache.qpid.test.utils.TestFileUtils; - -/** - * Tests the production of the different chart types. To manually - * verify the generated output, set the system property {@link #RETAIN_TEST_CHARTS} - * to prevent the automatic deletion of the test chart directory. - */ -public class ChartProductionTest extends QpidTestCase -{ - private static final Logger _logger = LoggerFactory.getLogger(ChartProductionTest.class); - private static final String TEST_CHARTTITLE = "TEST_CHARTTITLE"; - private static final String TEST_CHARTSUBTITLE = "TEST_CHARTSUBTITLE"; - private static final String TEST_XAXIS = "TEST_XAXIS"; - private static final String TEST_YAXIS = "TEST_YAXIS"; - - private static final String TEST_SERIESLEGEND = "TEST_SERIESLEGEND"; - - private static final SeriesRow[] SIMPLE_SERIES_ROWS = new SeriesRow[] - { - new SeriesRow(1d, 1d), - new SeriesRow(2d, 2d), - new SeriesRow(3d, 3d), - new SeriesRow(4d, 4d), - new SeriesRow(5d, 5d), - new SeriesRow(6d, 6d), - }; - - private static final String RETAIN_TEST_CHARTS = "retainTestCharts"; - - private SeriesDefinition _seriesDefinition = mock(SeriesDefinition.class); - private ChartingDefinition _chartingDefinition = mock(ChartingDefinition.class); - private ChartWriter _writer = new ChartWriter(); - - @Override - protected void setUp() throws Exception - { - super.setUp(); - - when(_seriesDefinition.getSeriesLegend()).thenReturn(TEST_SERIESLEGEND); - when(_seriesDefinition.getStrokeWidth()).thenReturn(null); - when(_seriesDefinition.getSeriesColourName()).thenReturn(null); - - when(_chartingDefinition.getChartStemName()).thenReturn(getName()); - when(_chartingDefinition.getChartTitle()).thenReturn(TEST_CHARTTITLE); - when(_chartingDefinition.getChartSubtitle()).thenReturn(TEST_CHARTSUBTITLE); - when(_chartingDefinition.getXAxisTitle()).thenReturn(TEST_XAXIS); - when(_chartingDefinition.getYAxisTitle()).thenReturn(TEST_YAXIS); - when(_chartingDefinition.getSeriesDefinitions()).thenReturn(Collections.singletonList(_seriesDefinition)); - - File chartDir = TestFileUtils.createTestDirectory("charts", false); - if (!System.getProperties().containsKey(RETAIN_TEST_CHARTS)) - { - chartDir.deleteOnExit(); - } - else - { - _logger.info("Charting directory for manual observation " + chartDir); - } - - _writer.setOutputDirectory(chartDir); - } - - public void testBarChart() throws Exception - { - ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.BAR, new SampleSeriesBuilder(SIMPLE_SERIES_ROWS)); - assertChartTitlesAndWriteToFile(builder); - } - - public void testBar3DChart() throws Exception - { - ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.BAR3D, new SampleSeriesBuilder()); - assertChartTitlesAndWriteToFile(builder); - } - - public void testLineChart() throws Exception - { - ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.LINE, new SampleSeriesBuilder()); - assertChartTitlesAndWriteToFile(builder); - } - - public void testLine3DChart() throws Exception - { - ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.LINE3D, new SampleSeriesBuilder()); - assertChartTitlesAndWriteToFile(builder); - } - - public void testXYLineChart() throws Exception - { - ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.XYLINE, new SampleSeriesBuilder()); - assertChartTitlesAndWriteToFile(builder); - } - - public void testXYLineChartWithColourAndWidth() throws Exception - { - when(_seriesDefinition.getStrokeWidth()).thenReturn(3); - when(_seriesDefinition.getSeriesColourName()).thenReturn("dark_orange"); - - ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.XYLINE, new SampleSeriesBuilder()); - assertChartTitlesAndWriteToFile(builder); - } - - public void testTimeSeriesLineChart() throws Exception - { - SeriesRow[] timelineSeriesRows = new SeriesRow[] - { - new SeriesRow(new Date(1), 1d), - new SeriesRow(new Date(2), 2d), - new SeriesRow(new Date(3), 3d), - new SeriesRow(new Date(4), 4d), - new SeriesRow(new Date(5), 5d), - new SeriesRow(new Date(6), 6d), - }; - ChartBuilder builder = ChartBuilderFactory.createChartBuilder( - ChartType.TIMELINE, - new SampleSeriesBuilder(timelineSeriesRows)); - - assertChartTitlesAndWriteToFile(builder); - } - - public void testStatisticalBarChart() throws Exception - { - SeriesRow[] statisticalSeriesRows = new SeriesRow[] - { - new SeriesRow(1d, 1d, 0.5d), - new SeriesRow(2d, 2d, 0.4d), - new SeriesRow(4d, 4d, 0.3d), - new SeriesRow(5d, 5d, 0.2d), - new SeriesRow(6d, 6d, 0.1d) - }; - - ChartBuilder builder = ChartBuilderFactory.createChartBuilder( - ChartType.STATISTICAL_BAR, - new SampleSeriesBuilder(statisticalSeriesRows)); - - assertChartTitlesAndWriteToFile(builder); - } - - private void assertChartTitlesAndWriteToFile(ChartBuilder builder) - { - JFreeChart chart = builder.buildChart(_chartingDefinition); - assertEquals(TEST_CHARTTITLE, chart.getTitle().getText()); - assertEquals(TEST_CHARTSUBTITLE, ((ShortTextTitle)chart.getSubtitle(1)).getText()); - assertEquals(TEST_SERIESLEGEND, chart.getPlot().getLegendItems().get(0).getLabel()); - - if (chart.getPlot() instanceof XYPlot) - { - assertEquals(1, chart.getXYPlot().getDatasetCount()); - } - else - { - assertEquals(1, chart.getCategoryPlot().getDatasetCount()); - } - - _writer.writeChartToFileSystem(chart, _chartingDefinition); - } - - private class SampleSeriesBuilder implements SeriesBuilder - { - private DatasetHolder _datasetHolder; - private SeriesRow[] _sampleSeriesRows = SIMPLE_SERIES_ROWS; - - public SampleSeriesBuilder() - { - } - - public SampleSeriesBuilder(SeriesRow[] sampleSeriesRows) - { - _sampleSeriesRows = sampleSeriesRows; - } - - @Override - public Dataset build(List<SeriesDefinition> seriesDefinitions) - { - for (Iterator<SeriesDefinition> iterator = seriesDefinitions.iterator(); iterator.hasNext();) - { - SeriesDefinition seriesDefinition = iterator.next(); - _datasetHolder.beginSeries(seriesDefinition); - for(SeriesRow seriesRow : _sampleSeriesRows) - { - _datasetHolder.addDataPointToSeries(seriesDefinition, seriesRow); - } - _datasetHolder.endSeries(seriesDefinition); - } - return _datasetHolder.getPopulatedDataset(); - } - - @Override - public void setDatasetHolder(DatasetHolder dataPointCallback) - { - _datasetHolder = dataPointCallback; - } - } -} diff --git a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactoryTest.java b/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactoryTest.java deleted file mode 100644 index 2656c780bb..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ColorFactoryTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - -import java.awt.Color; - -import org.apache.qpid.test.utils.QpidTestCase; - -public class ColorFactoryTest extends QpidTestCase -{ - public void testBlue() - { - assertEquals(Color.blue, ColorFactory.toColour("blue")); - assertEquals(Color.blue, ColorFactory.toColour("BLUE")); - assertEquals(Color.blue, ColorFactory.toColour("Blue")); - } - - public void testDarkBlue() - { - assertEquals(Color.blue.darker(), ColorFactory.toColour("dark_blue")); - assertEquals(Color.blue.darker(), ColorFactory.toColour("DARK_BLUE")); - assertEquals(Color.blue.darker(), ColorFactory.toColour("Dark_Blue")); - } - -}
\ No newline at end of file diff --git a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/TimeSeriesBuilderCallbackTest.java b/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/TimeSeriesBuilderCallbackTest.java deleted file mode 100644 index 88e76e667c..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/TimeSeriesBuilderCallbackTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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.qpid.disttest.charting.chartbuilder; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.Calendar; -import java.util.Date; -import java.util.TimeZone; - -import org.apache.qpid.disttest.charting.definition.SeriesDefinition; -import org.apache.qpid.disttest.charting.seriesbuilder.SeriesRow; -import org.apache.qpid.test.utils.QpidTestCase; -import org.jfree.data.time.TimeSeries; -import org.jfree.data.time.TimeSeriesCollection; -import org.jfree.data.time.TimeSeriesDataItem; - -public class TimeSeriesBuilderCallbackTest extends QpidTestCase -{ - private static final String SERIES_LEGEND = "mySeriesLegend"; - - private static final int NUMBER_OF_DATA_POINTS = 3; - - private Date[] _dates; - private double[] _values; - - @Override - protected void setUp() throws Exception - { - super.setUp(); - Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+00:00")); - - calendar.set(2013, Calendar.JANUARY, 1); - Date jan1 = calendar.getTime(); - - calendar.set(2013, Calendar.JANUARY, 2); - Date jan2 = calendar.getTime(); - - calendar.set(2013, Calendar.JANUARY, 3); - Date jan3 = calendar.getTime(); - - _dates = new Date[] {jan1, jan2, jan3}; - _values = new double[] {2.0, 4.0, 8.0}; - } - - - public void testAddPointToSeries() - { - TimeSeriesHolder timeSeriesHolder = new TimeSeriesHolder(); - - SeriesDefinition seriesDefinition = mock(SeriesDefinition.class); - when(seriesDefinition.getSeriesLegend()).thenReturn(SERIES_LEGEND); - - timeSeriesHolder.beginSeries(seriesDefinition); - - timeSeriesHolder.addDataPointToSeries(seriesDefinition, new SeriesRow(_dates[0], _values[0])); - timeSeriesHolder.addDataPointToSeries(seriesDefinition, new SeriesRow(_dates[1], _values[1])); - timeSeriesHolder.addDataPointToSeries(seriesDefinition, new SeriesRow(_dates[2], _values[2])); - - timeSeriesHolder.endSeries(seriesDefinition); - - TimeSeriesCollection timeSeriesCollection = (TimeSeriesCollection) timeSeriesHolder.getPopulatedDataset(); - - TimeSeries actualTimeSeries = timeSeriesCollection.getSeries(SERIES_LEGEND); - for(int i = 0; i < NUMBER_OF_DATA_POINTS; i++) - { - TimeSeriesDataItem dataItem0 = actualTimeSeries.getDataItem(i); - assertEquals(_dates[i].getTime(), dataItem0.getPeriod().getMiddleMillisecond()); - assertEquals(_values[i], dataItem0.getValue()); - } - } - -} diff --git a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreatorTest.java b/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreatorTest.java deleted file mode 100644 index 47eee43002..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreatorTest.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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.qpid.disttest.charting.definition; - -import static org.apache.qpid.disttest.charting.definition.ChartingDefinitionCreator.CHART_DESCRIPTION_KEY; -import static org.apache.qpid.disttest.charting.definition.ChartingDefinitionCreator.CHART_SUBTITLE_KEY; -import static org.apache.qpid.disttest.charting.definition.ChartingDefinitionCreator.CHART_TITLE_KEY; -import static org.apache.qpid.disttest.charting.definition.ChartingDefinitionCreator.CHART_TYPE_KEY; -import static org.apache.qpid.disttest.charting.definition.ChartingDefinitionCreator.XAXIS_TITLE_KEY; -import static org.apache.qpid.disttest.charting.definition.ChartingDefinitionCreator.YAXIS_TITLE_KEY; -import static org.apache.qpid.disttest.charting.definition.SeriesDefinitionCreator.SERIES_STATEMENT_KEY_FORMAT; - -import java.io.File; -import java.io.FileWriter; -import java.util.List; -import java.util.Properties; - -import org.apache.qpid.disttest.charting.ChartType; -import org.apache.qpid.disttest.charting.ChartingException; -import org.apache.qpid.test.utils.QpidTestCase; - -public class ChartingDefinitionCreatorTest extends QpidTestCase -{ - private static final String TEST_CHART_TITLE = "CHART_TITLE ${ChartingDefinitionSysProp}"; - private static final String TEST_CHART_SUBTITLE = "CHART_SUBTITLE"; - private static final String TEST_CHART_DESCRIPTION = "CHART_DESCRIPTION"; - private static final String TEST_XAXIS_TITLE = "XAXIS_TITLE"; - private static final String TEST_YAXIS_TITLE = "YAXIS_TITLE"; - private static final ChartType TEST_CHART_TYPE = ChartType.LINE; - - private static final String TEST_SERIES_SELECT_STATEMENT = "SERIES_SELECT_STATEMENT"; - - private static final String SYSTEM_PROPERTY_NAME = "ChartingDefinitionSysProp"; - - private ChartingDefinitionCreator _chartingDefinitionLoader = new ChartingDefinitionCreator(); - private File _testTempDir; - - @Override - protected void setUp() throws Exception - { - super.setUp(); - _testTempDir = createTestTemporaryDirectory(); - } - - public void testLoadTwoDefinitionsFromDirectory() throws Exception - { - createTestDefinitionWithin(_testTempDir); - createTestDefinitionWithin(_testTempDir); - - List<ChartingDefinition> definitions = _chartingDefinitionLoader.createFromFileOrDirectory(_testTempDir.getAbsolutePath()); - assertEquals(2, definitions.size()); - } - - public void testLoadOneDefinitionFromFile() throws Exception - { - File testDefFile = createTestDefinitionWithin(_testTempDir); - - List<ChartingDefinition> definitions = _chartingDefinitionLoader.createFromFileOrDirectory(testDefFile.getAbsolutePath()); - assertEquals(1, definitions.size()); - - ChartingDefinition definition1 = definitions.get(0); - assertEquals(TEST_CHART_TITLE, definition1.getChartTitle()); - } - - public void testDefinitionsProperties() throws Exception - { - setTestSystemProperty(SYSTEM_PROPERTY_NAME, "propValue"); - File testDefFile = createTestDefinitionWithin(_testTempDir); - - List<ChartingDefinition> definitions = _chartingDefinitionLoader.createFromFileOrDirectory(testDefFile.getAbsolutePath()); - assertEquals(1, definitions.size()); - - ChartingDefinition definition1 = definitions.get(0); - assertEquals("CHART_TITLE propValue", definition1.getChartTitle()); - assertEquals(TEST_CHART_SUBTITLE, definition1.getChartSubtitle()); - assertEquals(TEST_CHART_DESCRIPTION, definition1.getChartDescription()); - assertEquals(TEST_XAXIS_TITLE, definition1.getXAxisTitle()); - assertEquals(TEST_YAXIS_TITLE, definition1.getYAxisTitle()); - assertEquals(TEST_CHART_TYPE, definition1.getChartType()); - - String stemOnly = testDefFile.getName().replaceFirst("\\.chartdef", ""); - assertEquals(stemOnly, definition1.getChartStemName()); - - final List<SeriesDefinition> seriesDefinitions = definition1.getSeriesDefinitions(); - assertEquals(1, seriesDefinitions.size()); - SeriesDefinition seriesDefinition = seriesDefinitions.get(0); - assertEquals(TEST_SERIES_SELECT_STATEMENT, seriesDefinition.getSeriesStatement()); - } - - public void testDefinitionFileNotFound() throws Exception - { - File notFound = new File(_testTempDir,"notfound.chartdef"); - assertFalse(notFound.exists()); - - try - { - _chartingDefinitionLoader.createFromFileOrDirectory(notFound.getAbsolutePath()); - fail("Exception not thrown"); - } - catch(ChartingException ce) - { - // PASS - } - } - - private File createTestDefinitionWithin(File _testTempDir) throws Exception - { - final String testDefFileName = "test." + System.nanoTime() + ".chartdef"; - File chartDef = new File(_testTempDir, testDefFileName); - chartDef.createNewFile(); - - Properties props = new Properties(); - props.setProperty(CHART_TYPE_KEY, TEST_CHART_TYPE.name()); - props.setProperty(CHART_TITLE_KEY, TEST_CHART_TITLE); - props.setProperty(CHART_SUBTITLE_KEY, TEST_CHART_SUBTITLE); - props.setProperty(CHART_DESCRIPTION_KEY, TEST_CHART_DESCRIPTION); - props.setProperty(XAXIS_TITLE_KEY, TEST_XAXIS_TITLE); - props.setProperty(YAXIS_TITLE_KEY, TEST_YAXIS_TITLE); - - props.setProperty(String.format(SERIES_STATEMENT_KEY_FORMAT, 1), TEST_SERIES_SELECT_STATEMENT); - - final FileWriter writer = new FileWriter(chartDef); - try - { - props.store(writer, "Test chart definition file"); - } - finally - { - writer.close(); - } - - return chartDef; - } - - private File createTestTemporaryDirectory() throws Exception - { - File tmpDir = new File(System.getProperty("java.io.tmpdir"), "testdef" + System.nanoTime()); - tmpDir.mkdirs(); - tmpDir.deleteOnExit(); - return tmpDir; - } -} diff --git a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreatorTest.java b/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreatorTest.java deleted file mode 100644 index e937e80108..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreatorTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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.qpid.disttest.charting.definition; - -import static org.apache.qpid.disttest.charting.definition.SeriesDefinitionCreator.SERIES_COLOUR_NAME_FORMAT; -import static org.apache.qpid.disttest.charting.definition.SeriesDefinitionCreator.SERIES_DIRECTORY_KEY_FORMAT; -import static org.apache.qpid.disttest.charting.definition.SeriesDefinitionCreator.SERIES_LEGEND_KEY_FORMAT; -import static org.apache.qpid.disttest.charting.definition.SeriesDefinitionCreator.SERIES_STATEMENT_KEY_FORMAT; -import static org.apache.qpid.disttest.charting.definition.SeriesDefinitionCreator.SERIES_STROKE_WIDTH_FORMAT; - -import java.util.List; -import java.util.Properties; - -import org.apache.qpid.test.utils.QpidTestCase; - -public class SeriesDefinitionCreatorTest extends QpidTestCase -{ - private static final String SYSTEM_PROPERTY_NAME = "SeriesDefinitionProp"; - private static final String TEST_SERIES_1_SELECT_STATEMENT = "SERIES_1_SELECT_STATEMENT"; - private static final String TEST_SERIES_1_LEGEND = "SERIES_1_LEGEND"; - private static final String TEST_SERIES_1_LEGEND_WITH_SYSPROP = "SERIES_1_LEGEND ${SeriesDefinitionProp}"; - private static final String TEST_SERIES_1_DIR = "SERIES_1_DIR"; - private static final String TEST_SERIES_1_COLOUR_NAME = "seriesColourName"; - private static final Integer TEST_SERIES_1_STROKE_WIDTH = 1;; - - private static final String TEST_SERIES_1_DIR_WITH_SYSPROP = "${SeriesDefinitionProp}/mydir"; - - private static final String TEST_SERIES_2_SELECT_STATEMENT = "SERIES_2_SELECT_STATEMENT"; - private static final String TEST_SERIES_2_LEGEND = "SERIES_2_LEGEND"; - private static final String TEST_SERIES_2_DIR = "SERIES_2_DIR"; - - private Properties _properties = new Properties(); - - private SeriesDefinitionCreator _seriesDefinitionLoader = new SeriesDefinitionCreator(); - - @Override - protected void setUp() throws Exception - { - super.setUp(); - } - - public void testOneSeriesDefinition() throws Exception - { - createTestProperties(1, TEST_SERIES_1_SELECT_STATEMENT, TEST_SERIES_1_LEGEND, TEST_SERIES_1_DIR, TEST_SERIES_1_COLOUR_NAME, TEST_SERIES_1_STROKE_WIDTH); - - List<SeriesDefinition> definitions = _seriesDefinitionLoader.createFromProperties(_properties); - assertEquals(1, definitions.size()); - - SeriesDefinition definition = definitions.get(0); - assertEquals(TEST_SERIES_1_SELECT_STATEMENT, definition.getSeriesStatement()); - assertEquals(TEST_SERIES_1_LEGEND, definition.getSeriesLegend()); - assertEquals(TEST_SERIES_1_DIR, definition.getSeriesDirectory()); - assertEquals(TEST_SERIES_1_COLOUR_NAME, definition.getSeriesColourName()); - assertEquals(TEST_SERIES_1_STROKE_WIDTH, definition.getStrokeWidth()); - } - - public void testTwoSeriesDefinitions() throws Exception - { - createTestProperties(1, TEST_SERIES_1_SELECT_STATEMENT, TEST_SERIES_1_LEGEND, TEST_SERIES_1_DIR, TEST_SERIES_1_COLOUR_NAME, TEST_SERIES_1_STROKE_WIDTH); - createTestProperties(2, TEST_SERIES_2_SELECT_STATEMENT, TEST_SERIES_2_LEGEND, TEST_SERIES_2_DIR, null, null); - - List<SeriesDefinition> definitions = _seriesDefinitionLoader.createFromProperties(_properties); - assertEquals(2, definitions.size()); - - SeriesDefinition seriesDefinition1 = definitions.get(0); - assertEquals(TEST_SERIES_1_SELECT_STATEMENT, seriesDefinition1.getSeriesStatement()); - assertEquals(TEST_SERIES_1_LEGEND, seriesDefinition1.getSeriesLegend()); - assertEquals(TEST_SERIES_1_DIR, seriesDefinition1.getSeriesDirectory()); - - SeriesDefinition seriesDefinition2 = definitions.get(1); - assertEquals(TEST_SERIES_2_SELECT_STATEMENT, seriesDefinition2.getSeriesStatement()); - assertEquals(TEST_SERIES_2_LEGEND, seriesDefinition2.getSeriesLegend()); - assertEquals(TEST_SERIES_2_DIR, seriesDefinition2.getSeriesDirectory()); - } - - public void testNonSequentialSeriesDefinitionsIgnored() throws Exception - { - createTestProperties(1, TEST_SERIES_1_SELECT_STATEMENT, TEST_SERIES_1_LEGEND, TEST_SERIES_1_DIR, TEST_SERIES_1_COLOUR_NAME, TEST_SERIES_1_STROKE_WIDTH); - createTestProperties(3, TEST_SERIES_2_SELECT_STATEMENT, TEST_SERIES_2_LEGEND, TEST_SERIES_2_DIR, null, null); - - List<SeriesDefinition> definitions = _seriesDefinitionLoader.createFromProperties(_properties); - assertEquals(1, definitions.size()); - } - - public void testSeriesDirectoryAndNameSubstitution() throws Exception - { - setTestSystemProperty(SYSTEM_PROPERTY_NAME, "propValue"); - createTestProperties(1, TEST_SERIES_1_SELECT_STATEMENT, TEST_SERIES_1_LEGEND_WITH_SYSPROP, TEST_SERIES_1_DIR_WITH_SYSPROP, null, null); - - List<SeriesDefinition> definitions = _seriesDefinitionLoader.createFromProperties(_properties); - assertEquals(1, definitions.size()); - - SeriesDefinition seriesDefinition1 = definitions.get(0); - assertEquals("propValue/mydir", seriesDefinition1.getSeriesDirectory()); - assertEquals("SERIES_1_LEGEND propValue", seriesDefinition1.getSeriesLegend()); - } - - private void createTestProperties(int index, String selectStatement, String seriesLegend, String seriesDir, String seriesColourName, Integer seriesStrokeWidth) throws Exception - { - _properties.setProperty(String.format(SERIES_STATEMENT_KEY_FORMAT, index), selectStatement); - _properties.setProperty(String.format(SERIES_LEGEND_KEY_FORMAT, index), seriesLegend); - _properties.setProperty(String.format(SERIES_DIRECTORY_KEY_FORMAT, index), seriesDir); - if (seriesColourName != null) - { - _properties.setProperty(String.format(SERIES_COLOUR_NAME_FORMAT, index), seriesColourName); - } - if (seriesStrokeWidth != null) - { - _properties.setProperty(String.format(SERIES_STROKE_WIDTH_FORMAT, index), seriesStrokeWidth.toString()); - } - } - -} diff --git a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcSeriesBuilderTest.java b/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcSeriesBuilderTest.java deleted file mode 100644 index b6b4dbe56b..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcSeriesBuilderTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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.qpid.disttest.charting.seriesbuilder; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.PrintWriter; -import java.util.Collections; - -import org.apache.qpid.disttest.charting.definition.SeriesDefinition; -import org.apache.qpid.test.utils.QpidTestCase; - -public class JdbcSeriesBuilderTest extends QpidTestCase -{ - private static final String TEST_SERIES_1_SELECT_STATEMENT = "SELECT A, B FROM test"; - private static final String TEST_SERIES_1_LEGEND = "SERIES_1_LEGEND"; - private static final String TEST_SERIES1_COLOUR_NAME = "blue"; - private static final Integer TEST_SERIES1_STROKE_WIDTH = 3; - - private DatasetHolder _seriesWalkerCallback = mock(DatasetHolder.class); - - private File _testTempDir; - - @Override - protected void setUp() throws Exception - { - super.setUp(); - when(_seriesWalkerCallback.getNumberOfDimensions()).thenReturn(2); - _testTempDir = createTestTemporaryDirectory(); - createTestCsvIn(_testTempDir); - } - - public void testBuildOneSeries() throws Exception - { - SeriesDefinition seriesDefinition = createTestSeriesDefinition(); - - JdbcSeriesBuilder seriesBuilder = new JdbcSeriesBuilder("org.relique.jdbc.csv.CsvDriver", null); - - seriesBuilder.setDatasetHolder(_seriesWalkerCallback); - - seriesBuilder.build(Collections.singletonList(seriesDefinition)); - - verify(_seriesWalkerCallback).beginSeries(seriesDefinition); - verify(_seriesWalkerCallback).addDataPointToSeries(seriesDefinition, new SeriesRow("elephant", "2")); - verify(_seriesWalkerCallback).addDataPointToSeries(seriesDefinition, new SeriesRow("lion", "3")); - verify(_seriesWalkerCallback).addDataPointToSeries(seriesDefinition, new SeriesRow("tiger", "4")); - verify(_seriesWalkerCallback).endSeries(seriesDefinition); - } - - private void createTestCsvIn(File testDir) throws Exception - { - File csv = new File(_testTempDir, "test.csv"); - - PrintWriter csvWriter = new PrintWriter(new BufferedWriter(new FileWriter(csv))); - csvWriter.println("A,B"); - csvWriter.println("elephant,2"); - csvWriter.println("lion,3"); - csvWriter.println("tiger,4"); - csvWriter.close(); - } - - private SeriesDefinition createTestSeriesDefinition() - { - SeriesDefinition definition = new SeriesDefinition( - TEST_SERIES_1_SELECT_STATEMENT, - TEST_SERIES_1_LEGEND, - _testTempDir.getAbsolutePath(), - TEST_SERIES1_COLOUR_NAME, - TEST_SERIES1_STROKE_WIDTH); - return definition; - } - - private File createTestTemporaryDirectory() throws Exception - { - File tmpDir = new File(System.getProperty("java.io.tmpdir"), "testdef" + System.nanoTime()); - tmpDir.mkdirs(); - tmpDir.deleteOnExit(); - return tmpDir; - } - -} diff --git a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcUrlGeneratorTest.java b/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcUrlGeneratorTest.java deleted file mode 100644 index d53d0ccfe1..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/JdbcUrlGeneratorTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.qpid.disttest.charting.seriesbuilder; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.apache.qpid.disttest.charting.definition.SeriesDefinition; -import org.apache.qpid.test.utils.QpidTestCase; - -public class JdbcUrlGeneratorTest extends QpidTestCase -{ - public void testGetJdbcUrlWithoutProvidingAUrlReturnsCsvUrlWithCorrectDirectory() - { - JdbcUrlGenerator jdbcUrlGenerator = new JdbcUrlGenerator(null); - SeriesDefinition seriesDefinition = mock(SeriesDefinition.class); - when(seriesDefinition.getSeriesDirectory()).thenReturn("mydir"); - - String jdbcUrl = jdbcUrlGenerator.getJdbcUrl(seriesDefinition); - - assertEquals("jdbc:relique:csv:mydir", jdbcUrl); - } - - public void testGetJdbcUrlReturnsProvidedUrl() - { - String urlTemplate = "urlTemplate"; - JdbcUrlGenerator jdbcUrlGenerator = new JdbcUrlGenerator(urlTemplate); - SeriesDefinition seriesDefinition = mock(SeriesDefinition.class); - - String jdbcUrl = jdbcUrlGenerator.getJdbcUrl(seriesDefinition); - - assertEquals(urlTemplate, jdbcUrl); - } - - public void testGetJdbcUrlThrowsExceptionIfUrlProvidedAndSeriesDirectorySpecified() - { - String urlTemplate = "urlTemplate"; - JdbcUrlGenerator jdbcUrlGenerator = new JdbcUrlGenerator(urlTemplate); - SeriesDefinition seriesDefinition = mock(SeriesDefinition.class); - when(seriesDefinition.getSeriesDirectory()).thenReturn("mydir"); - - try - { - jdbcUrlGenerator.getJdbcUrl(seriesDefinition); - fail("Expected exception not thrown"); - } - catch (IllegalArgumentException e) - { - // pass - } - } - - public void testGetJdbcUrlThrowsExceptionWithoutAProvidedUrlOrSeriesDirectory() - { - JdbcUrlGenerator jdbcUrlGenerator = new JdbcUrlGenerator(null); - SeriesDefinition seriesDefinition = mock(SeriesDefinition.class); - when(seriesDefinition.getSeriesDirectory()).thenReturn(null); - - try - { - jdbcUrlGenerator.getJdbcUrl(seriesDefinition); - fail("Expected exception not thrown"); - } - catch (IllegalArgumentException e) - { - // pass - } - } -} diff --git a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesRowTest.java b/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesRowTest.java deleted file mode 100644 index 064971aa35..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/seriesbuilder/SeriesRowTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.qpid.disttest.charting.seriesbuilder; - -import org.apache.qpid.test.utils.QpidTestCase; - -public class SeriesRowTest extends QpidTestCase -{ - private static final Integer[] PAIR = new Integer[] {10, 11}; - - public void testValidSeriesRow() - { - assertEquals(11, SeriesRow.createValidSeriesRow(2, PAIR).dimension(1)); - } - - public void testValidSeriesRowThrowsExceptionIfArrayTooSmall() - { - try - { - SeriesRow.createValidSeriesRow(1, PAIR); - fail("Expected exception not thrown"); - } - catch(IllegalArgumentException e) - { - // pass - } - } - - public void testDimension() - { - SeriesRow seriesRow = new SeriesRow(10, 11); - assertEquals(10, seriesRow.dimension(0)); - assertEquals(11, seriesRow.dimension(1)); - } - - public void testDimensionAsString() - { - SeriesRow seriesRow = new SeriesRow(10); - assertEquals("10", seriesRow.dimensionAsString(0)); - } - - public void testDimensionAsDouble() - { - SeriesRow seriesRow = new SeriesRow(10.1); - assertEquals(10.1, seriesRow.dimensionAsDouble(0), 0.0); - } - -} diff --git a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/ChartWriterTest.java b/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/ChartWriterTest.java deleted file mode 100644 index 9703c66e1f..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/ChartWriterTest.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * - * 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.qpid.disttest.charting.writer; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.File; -import java.io.FileWriter; -import java.io.InputStream; -import java.util.Scanner; - -import org.apache.qpid.disttest.charting.definition.ChartingDefinition; -import org.apache.qpid.test.utils.QpidTestCase; -import org.apache.qpid.test.utils.TestFileUtils; -import org.apache.qpid.util.FileUtils; -import org.jfree.chart.ChartFactory; -import org.jfree.chart.JFreeChart; -import org.jfree.data.general.DefaultPieDataset; - -public class ChartWriterTest extends QpidTestCase -{ - private JFreeChart _chart1; - private JFreeChart _chart2; - - private File _chartDir; - private ChartWriter _writer; - - @Override - public void setUp() - { - DefaultPieDataset dataset = new DefaultPieDataset(); - dataset.setValue("a", 1); - dataset.setValue("b", 2); - - _chart1 = ChartFactory.createPieChart("chart1", dataset, true, true, false); - _chart2 = ChartFactory.createPieChart("chart2", dataset, true, true, false); - - _chartDir = TestFileUtils.createTestDirectory(); - - _writer = new ChartWriter(); - _writer.setOutputDirectory(_chartDir); - } - - public void testWriteChartToFileSystem() - { - ChartingDefinition chartDef1 = mock(ChartingDefinition.class); - when(chartDef1.getChartStemName()).thenReturn("chart1"); - - File chart1File = new File(_chartDir, "chart1.png"); - assertFalse("chart1 png should not exist yet", chart1File.exists()); - - _writer.writeChartToFileSystem(_chart1, chartDef1); - - assertTrue("chart1 png does not exist", chart1File.exists()); - } - - public void testWriteHtmlSummaryToFileSystemOverwritingExistingFile() throws Exception - { - ChartingDefinition chartDef1 = mock(ChartingDefinition.class); - when(chartDef1.getChartStemName()).thenReturn("chart1"); - when(chartDef1.getChartDescription()).thenReturn("chart description1"); - - ChartingDefinition chartDef2 = mock(ChartingDefinition.class); - when(chartDef2.getChartStemName()).thenReturn("chart2"); - - File summaryFile = new File(_chartDir, ChartWriter.SUMMARY_FILE_NAME); - - writeDummyContentToSummaryFileToEnsureItGetsOverwritten(summaryFile); - - _writer.writeChartToFileSystem(_chart2, chartDef2); - _writer.writeChartToFileSystem(_chart1, chartDef1); - - _writer.writeHtmlSummaryToFileSystem("Performance Charts"); - - InputStream expectedSummaryFileInputStream = getClass().getResourceAsStream("expected-chart-summary.html"); - String expectedSummaryContent = new Scanner(expectedSummaryFileInputStream).useDelimiter("\\A").next(); - String actualSummaryContent = FileUtils.readFileAsString(summaryFile); - - assertEquals("HTML summary file has unexpected content", expectedSummaryContent, actualSummaryContent); - } - - public void testWriteHtmlSummaryToFileSystemDoesNothingIfLessThanTwoCharts() - { - ChartingDefinition chartDef1 = mock(ChartingDefinition.class); - when(chartDef1.getChartStemName()).thenReturn("chart1"); - when(chartDef1.getChartDescription()).thenReturn("chart description1"); - - File summaryFile = new File(_chartDir, ChartWriter.SUMMARY_FILE_NAME); - - _writer.writeChartToFileSystem(_chart1, chartDef1); - - _writer.writeHtmlSummaryToFileSystem("Performance Charts"); - - assertFalse("Only one chart generated so no summary file should have been written", - summaryFile.exists()); - } - - private void writeDummyContentToSummaryFileToEnsureItGetsOverwritten(File summaryFile) throws Exception - { - FileWriter writer = null; - try - { - writer = new FileWriter(summaryFile); - writer.write("dummy content"); - writer.close(); - } - finally - { - if (writer != null) - { - writer.close(); - } - } - } -} diff --git a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/expected-chart-summary.html b/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/expected-chart-summary.html deleted file mode 100755 index e7dadcb05b..0000000000 --- a/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/writer/expected-chart-summary.html +++ /dev/null @@ -1,21 +0,0 @@ -<html> - <head> - <title>Performance Charts</title> - <style type='text/css'>figure { float: left; display: table; width: 87px;}</style> - </head> - <body> - <ul> - <li><a href='#chart1.png'>chart1.png</a></li> - <li><a href='#chart2.png'>chart2.png</a></li> - </ul> - <figure> - <a name='chart1.png'/> - <img src='chart1.png'/> - <figcaption>chart description1</figcaption> - </figure> - <figure> - <a name='chart2.png'/> - <img src='chart2.png'/> - </figure> - </body> -</html>
\ No newline at end of file |
