Quantcast

svn commit: r1332087 [4/4] - in /qpid/trunk/qpid/java: ./ perftests/etc/ perftests/etc/chartdefs/ perftests/etc/suite/ perftests/etc/testdefs/ perftests/etc/testdefs/short/ perftests/etc/testdefs/standard/ perftests/visualisation-jfc/ perftests/visuali...

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

svn commit: r1332087 [4/4] - in /qpid/trunk/qpid/java: ./ perftests/etc/ perftests/etc/chartdefs/ perftests/etc/suite/ perftests/etc/testdefs/ perftests/etc/testdefs/short/ perftests/etc/testdefs/standard/ perftests/visualisation-jfc/ perftests/visuali...

kwall
Added: qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartType.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartType.java?rev=1332087&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartType.java (added)
+++ qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartType.java Mon Apr 30 07:43:38 2012
@@ -0,0 +1,26 @@
+/*
+ * 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, BAR
+
+}

Added: qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingException.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingException.java?rev=1332087&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingException.java (added)
+++ qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingException.java Mon Apr 30 07:43:38 2012
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.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);
+    }
+
+}

Added: qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingUtil.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingUtil.java?rev=1332087&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingUtil.java (added)
+++ qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/ChartingUtil.java Mon Apr 30 07:43:38 2012
@@ -0,0 +1,135 @@
+/*
+ *
+ * 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.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+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.jfree.chart.ChartUtilities;
+import org.jfree.chart.JFreeChart;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ChartingUtil
+{
+    private static final Logger LOGGER = LoggerFactory.getLogger(ChartingUtil.class);
+
+    public static final String OUTPUT_DIR_PROP = "outputdir";
+    public static final String OUTPUT_DIR_DEFAULT = ".";
+
+    public static final String CHART_DEFINITIONS_PROP = "chart-defs";
+    public static final String CHART_DEFINITIONS_DEFAULT = ".";
+
+    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);
+    }
+
+    public static void main(String[] args) throws Exception
+    {
+        try
+        {
+            LOGGER.debug("Starting charting");
+
+            ChartingUtil chartingUtil = new ChartingUtil();
+            chartingUtil.parseArgumentsIntoConfig(args);
+            chartingUtil.produceAllCharts();
+        }
+        finally
+        {
+            LOGGER.debug("Charting complete");
+        }
+    }
+
+    private void produceAllCharts()
+    {
+        final String chartingDefsDir = _cliOptions.get(CHART_DEFINITIONS_PROP);
+        List<ChartingDefinition> definitions  = loadChartDefinitions(chartingDefsDir);
+
+        LOGGER.debug("There are {} chart(s) to produce", definitions.size());
+
+        for (ChartingDefinition chartingDefinition : definitions)
+        {
+            ChartBuilder chartBuilder = ChartBuilderFactory.createChartBuilder(chartingDefinition.getChartType());
+            JFreeChart chart = chartBuilder.buildChart(chartingDefinition);
+            writeChartToFileSystem(chart, chartingDefinition.getChartStemName());
+        }
+    }
+
+    private void writeChartToFileSystem(JFreeChart chart, String chartStemName)
+    {
+        OutputStream pngOutputStream = null;
+        try
+        {
+
+            File pngFile = new File(chartStemName + ".png");
+            pngOutputStream = new BufferedOutputStream(new FileOutputStream(pngFile));
+            ChartUtilities.writeChartAsPNG(pngOutputStream, chart, 600, 400, true, 0);
+            pngOutputStream.close();
+
+            LOGGER.debug("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);
+                }
+            }
+        }
+    }
+
+    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);
+    }
+
+
+}

Added: qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BarChartBuilder.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BarChartBuilder.java?rev=1332087&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BarChartBuilder.java (added)
+++ qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/BarChartBuilder.java Mon Apr 30 07:43:38 2012
@@ -0,0 +1,47 @@
+/*
+ * 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.jfree.chart.ChartFactory;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.data.category.DefaultCategoryDataset;
+
+public class BarChartBuilder extends DataSetBasedChartBuilder
+{
+
+    @Override
+    public JFreeChart createChartImpl(String title, String xAxisTitle,
+            String yAxisTitle, final DefaultCategoryDataset dataset, PlotOrientation plotOrientation,
+            boolean showLegend, boolean showToolTips, boolean showUrls)
+    {
+        JFreeChart chart = ChartFactory.createBarChart(title,
+                xAxisTitle,
+                yAxisTitle,
+                dataset,
+                plotOrientation,
+                showLegend,
+                showToolTips,
+                showUrls);
+        return chart;
+    }
+
+
+}

Added: qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilder.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilder.java?rev=1332087&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilder.java (added)
+++ qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilder.java Mon Apr 30 07:43:38 2012
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+public interface ChartBuilder
+{
+
+    public JFreeChart buildChart(ChartingDefinition chartingDefinition);
+
+}

Added: qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactory.java?rev=1332087&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactory.java (added)
+++ qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactory.java Mon Apr 30 07:43:38 2012
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+public class ChartBuilderFactory
+{
+
+    public static ChartBuilder createChartBuilder(ChartType chartType)
+    {
+        switch (chartType)
+        {
+        case LINE:
+            return new LineChartBuilder();
+        case BAR:
+            return new BarChartBuilder();
+        default:
+            throw new IllegalArgumentException("Unknown chart type " + chartType);
+        }
+    }
+
+}

Added: qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/DataPointCallback.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/DataPointCallback.java?rev=1332087&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/DataPointCallback.java (added)
+++ qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/DataPointCallback.java Mon Apr 30 07:43:38 2012
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+public interface DataPointCallback
+{
+    public void addDataPointToSeries(SeriesDefinition seriesDefinition, Object xValue, Object yValue);
+}

Added: qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/DataSetBasedChartBuilder.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/DataSetBasedChartBuilder.java?rev=1332087&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/DataSetBasedChartBuilder.java (added)
+++ qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/DataSetBasedChartBuilder.java Mon Apr 30 07:43:38 2012
@@ -0,0 +1,68 @@
+/*
+ * 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.apache.qpid.disttest.charting.definition.SeriesDefinition;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.axis.CategoryLabelPositions;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.data.category.DefaultCategoryDataset;
+
+public abstract class DataSetBasedChartBuilder implements ChartBuilder
+{
+    private static final CategoryLabelPositions LABEL_POSITION = CategoryLabelPositions.UP_45;
+    private static final PlotOrientation PLOT_ORIENTATION = PlotOrientation.VERTICAL;
+
+    @Override
+    public JFreeChart buildChart(ChartingDefinition chartingDefinition)
+    {
+        String title = chartingDefinition.getChartTitle();
+        String xAxisTitle = chartingDefinition.getXAxisTitle();
+        String yAxisTitle = chartingDefinition.getYAxisTitle();
+
+        final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
+
+        SeriesBuilder seriesBuilder = new SeriesBuilder(new DataPointCallback()
+        {
+            @Override
+            public void addDataPointToSeries(SeriesDefinition seriesDefinition,
+                    Object xValue, Object yValue)
+            {
+                String x = (String) xValue;
+                double y = (Double) yValue;
+                dataset.addValue( y, seriesDefinition.getSeriesLegend(), x);
+            }
+        });
+
+        seriesBuilder.build(chartingDefinition.getSeries());
+
+        JFreeChart chart = createChartImpl(title, xAxisTitle, yAxisTitle,
+                dataset, PLOT_ORIENTATION, true, false, false);
+
+        chart.getCategoryPlot().getDomainAxis().setCategoryLabelPositions(LABEL_POSITION);
+
+        return chart;
+    }
+
+    public abstract JFreeChart createChartImpl(String title, String xAxisTitle,
+            String yAxisTitle, final DefaultCategoryDataset dataset, PlotOrientation plotOrientation,
+            boolean showLegend, boolean showToolTips, boolean showUrls);
+}

Added: qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/LineChartBuilder.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/LineChartBuilder.java?rev=1332087&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/LineChartBuilder.java (added)
+++ qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/LineChartBuilder.java Mon Apr 30 07:43:38 2012
@@ -0,0 +1,45 @@
+/*
+ * 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.jfree.chart.ChartFactory;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.data.category.DefaultCategoryDataset;
+
+public class LineChartBuilder extends DataSetBasedChartBuilder
+{
+    @Override
+    public JFreeChart createChartImpl(String title, String xAxisTitle,
+            String yAxisTitle, final DefaultCategoryDataset dataset, PlotOrientation plotOrientation,
+            boolean showLegend, boolean showToolTips, boolean showUrls)
+    {
+        JFreeChart chart = ChartFactory.createLineChart(title,
+                                                        xAxisTitle,
+                                                        yAxisTitle,
+                                                        dataset,
+                                                        plotOrientation,
+                                                        showLegend,
+                                                        showToolTips,
+                                                        showUrls);
+        return chart;
+    }
+
+}

Added: qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesBuilder.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesBuilder.java?rev=1332087&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesBuilder.java (added)
+++ qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesBuilder.java Mon Apr 30 07:43:38 2012
@@ -0,0 +1,133 @@
+/*
+ * 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.io.File;
+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.qpid.disttest.charting.ChartingException;
+import org.apache.qpid.disttest.charting.definition.SeriesDefinition;
+
+public class SeriesBuilder
+{
+    static
+    {
+        registerCsvDriver();
+    }
+
+    private final DataPointCallback _dataPointCallback;
+
+    public SeriesBuilder(DataPointCallback dataPointCallback)
+    {
+        _dataPointCallback = dataPointCallback;
+    }
+
+    public void build(List<SeriesDefinition> seriesDefinitions)
+    {
+        for (Iterator<SeriesDefinition> iterator = seriesDefinitions.iterator(); iterator.hasNext();)
+        {
+            SeriesDefinition series = iterator.next();
+            buildDataSetForSingleSeries(series);
+        }
+    }
+
+    private void buildDataSetForSingleSeries(SeriesDefinition seriesDefinition)
+    {
+        Connection conn = null;
+        Statement stmt = null;
+        try
+        {
+            File seriesDir = getValidatedSeriesDirectory(seriesDefinition);
+
+            conn = DriverManager.getConnection("jdbc:relique:csv:" + seriesDir.getAbsolutePath());
+
+            final String seriesStatement = seriesDefinition.getSeriesStatement();
+
+            stmt = conn.createStatement();
+            ResultSet results = stmt.executeQuery(seriesStatement);
+
+            while (results.next())
+            {
+                Object xValue = results.getString(1);
+                Object yValue = results.getDouble(2);
+
+                _dataPointCallback.addDataPointToSeries(seriesDefinition, xValue, yValue);
+            }
+        }
+        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 File getValidatedSeriesDirectory(SeriesDefinition series)
+    {
+        File seriesDir = new File(series.getSeriesDirectory());
+        if (!seriesDir.isDirectory())
+        {
+            throw new ChartingException("seriesDirectory must be a directory : " + seriesDir);
+        }
+        return seriesDir;
+    }
+
+    private static void registerCsvDriver() throws ExceptionInInitializerError
+    {
+        try
+        {
+            Class.forName("org.relique.jdbc.csv.CsvDriver");
+        }
+        catch (ClassNotFoundException e)
+        {
+            throw new RuntimeException("Could not load CSV/JDBC driver", e);
+        }
+    }
+
+}

Added: qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinition.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinition.java?rev=1332087&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinition.java (added)
+++ qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinition.java Mon Apr 30 07:43:38 2012
@@ -0,0 +1,85 @@
+/*
+ * 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.qpid.disttest.charting.ChartType;
+
+public class ChartingDefinition
+{
+    private final String _chartStemName;
+    private final ChartType _chartType;
+    private final String _chartTitle;
+    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 xaxisTitle,
+                              final String yaxisTitle, List<SeriesDefinition> seriesDefinitions)
+    {
+        _chartStemName = chartStemName;
+        _chartType = chartType;
+        _chartTitle = chartTitle;
+        _xaxisTitle = xaxisTitle;
+        _yaxisTitle = yaxisTitle;
+        _seriesDefinitions = seriesDefinitions;
+    }
+
+    public String getChartStemName()
+    {
+        return _chartStemName;
+    }
+
+    public String getChartTitle()
+    {
+        return _chartTitle;
+    }
+
+
+    public String getXAxisTitle()
+    {
+        return _xaxisTitle;
+    }
+
+
+    public String getYAxisTitle()
+    {
+        return _yaxisTitle;
+    }
+
+
+
+    public ChartType getChartType()
+    {
+        return _chartType;
+    }
+
+    public List<SeriesDefinition> getSeries()
+    {
+        return Collections.unmodifiableList(_seriesDefinitions);
+    }
+
+}

Added: qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreator.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreator.java?rev=1332087&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreator.java (added)
+++ qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreator.java Mon Apr 30 07:43:38 2012
@@ -0,0 +1,140 @@
+/*
+ * 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.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 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(props.getProperty(CHART_TYPE_KEY));
+            final String chartTitle = props.getProperty(CHART_TITLE_KEY);
+            final String xAxisTitle = props.getProperty(XAXIS_TITLE_KEY);
+            final String yAxisTitle = props.getProperty(YAXIS_TITLE_KEY);
+
+            final List<SeriesDefinition> seriesDefinitions = createSeriesDefinitions(props);
+
+            final ChartingDefinition chartDefinition = new ChartingDefinition(chartStemName,
+                                                                              chartType,
+                                                                              chartTitle,
+                                                                              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);
+        }
+    }
+
+
+
+}

Added: qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinition.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinition.java?rev=1332087&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinition.java (added)
+++ qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinition.java Mon Apr 30 07:43:38 2012
@@ -0,0 +1,50 @@
+/*
+ * 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;
+
+public class SeriesDefinition
+{
+    private final String _seriesStatement;
+    private final String _seriesLegend;
+    private final String _seriesDirectory;
+
+    public SeriesDefinition(String seriesStatement, String seriesLegend, String seriesDirectory)
+    {
+        _seriesStatement = seriesStatement;
+        _seriesLegend = seriesLegend;
+        _seriesDirectory = seriesDirectory;
+    }
+
+    public String getSeriesStatement()
+    {
+        return _seriesStatement;
+    }
+
+    public String getSeriesLegend()
+    {
+        return _seriesLegend;
+    }
+
+    public String getSeriesDirectory()
+    {
+        return _seriesDirectory;
+    }
+
+}

Added: qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreator.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreator.java?rev=1332087&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreator.java (added)
+++ qpid/trunk/qpid/java/perftests/visualisation-jfc/src/main/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreator.java Mon Apr 30 07:43:38 2012
@@ -0,0 +1,60 @@
+/*
+ * 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.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.commons.lang.text.StrSubstitutor;
+
+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 List<SeriesDefinition> createFromProperties(Properties properties)
+    {
+        final List<SeriesDefinition> seriesDefinitions = new ArrayList<SeriesDefinition>();
+
+        int index = 1;
+        boolean moreSeriesDefinitions = true;
+        while(moreSeriesDefinitions)
+        {
+            String seriesStatement = properties.getProperty(String.format(SERIES_STATEMENT_KEY_FORMAT, index));
+            String seriesLegend = properties.getProperty(String.format(SERIES_LEGEND_KEY_FORMAT, index));
+            String seriesDir = StrSubstitutor.replaceSystemProperties(properties.getProperty(String.format(SERIES_DIRECTORY_KEY_FORMAT, index)));
+
+            if (seriesStatement != null)
+            {
+                final SeriesDefinition seriesDefinition = new SeriesDefinition(seriesStatement, seriesLegend, seriesDir);
+                seriesDefinitions.add(seriesDefinition);
+            }
+            else
+            {
+                moreSeriesDefinitions = false;
+            }
+            index++;
+        }
+        return seriesDefinitions;
+    }
+
+}

Added: qpid/trunk/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactoryTest.java?rev=1332087&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactoryTest.java (added)
+++ qpid/trunk/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/ChartBuilderFactoryTest.java Mon Apr 30 07:43:38 2012
@@ -0,0 +1,40 @@
+/*
+ * 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 junit.framework.TestCase;
+
+public class ChartBuilderFactoryTest extends TestCase
+{
+    public void testLineChart()
+    {
+        ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.LINE);
+        assertTrue(builder instanceof LineChartBuilder);
+    }
+
+    public void testBarChart()
+    {
+        ChartBuilder builder = ChartBuilderFactory.createChartBuilder(ChartType.BAR);
+        assertTrue(builder instanceof BarChartBuilder);
+    }
+
+}

Added: qpid/trunk/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesBuilderTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesBuilderTest.java?rev=1332087&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesBuilderTest.java (added)
+++ qpid/trunk/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/chartbuilder/SeriesBuilderTest.java Mon Apr 30 07:43:38 2012
@@ -0,0 +1,90 @@
+/*
+ * 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 java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.util.Collections;
+
+import junit.framework.TestCase;
+
+import org.apache.qpid.disttest.charting.definition.SeriesDefinition;
+
+public class SeriesBuilderTest extends TestCase
+{
+    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 DataPointCallback _dataPointCallback = mock(DataPointCallback.class);
+    private SeriesBuilder _seriesBuilder = new SeriesBuilder(_dataPointCallback);
+
+    private File _testTempDir;
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        _testTempDir = createTestTemporaryDirectory();
+    }
+
+    public void testBuildOneSeries() throws Exception
+    {
+        createTestCsvIn(_testTempDir);
+        SeriesDefinition seriesDefinition = createTestSeriesDefinition();
+
+        _seriesBuilder.build(Collections.singletonList(seriesDefinition));
+
+        verify(_dataPointCallback).addDataPointToSeries(seriesDefinition, (Object)"elephant", (Object)2.0);
+        verify(_dataPointCallback).addDataPointToSeries(seriesDefinition, (Object)"lion", (Object)3.0);
+        verify(_dataPointCallback).addDataPointToSeries(seriesDefinition, (Object)"tiger", (Object)4.0);
+    }
+
+    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());
+        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;
+    }
+
+}

Added: qpid/trunk/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreatorTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreatorTest.java?rev=1332087&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreatorTest.java (added)
+++ qpid/trunk/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/ChartingDefinitionCreatorTest.java Mon Apr 30 07:43:38 2012
@@ -0,0 +1,149 @@
+/*
+ * 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_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 junit.framework.TestCase;
+
+import org.apache.qpid.disttest.charting.ChartType;
+import org.apache.qpid.disttest.charting.ChartingException;
+
+public class ChartingDefinitionCreatorTest extends TestCase
+{
+    private static final String TEST_CHART_TITLE = "CHART_TITLE";
+    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 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
+    {
+        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());
+        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.getSeries();
+        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(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;
+    }
+}

Added: qpid/trunk/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreatorTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreatorTest.java?rev=1332087&view=auto
==============================================================================
--- qpid/trunk/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreatorTest.java (added)
+++ qpid/trunk/qpid/java/perftests/visualisation-jfc/src/test/java/org/apache/qpid/disttest/charting/definition/SeriesDefinitionCreatorTest.java Mon Apr 30 07:43:38 2012
@@ -0,0 +1,113 @@
+/*
+ * 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_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 java.util.List;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+public class SeriesDefinitionCreatorTest extends TestCase
+{
+    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_DIR = "SERIES_1_DIR";
+
+    private static final String TEST_SERIES_1_DIR_WITH_SYSPROP = "${java.io.tmpdir}/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);
+
+        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());
+    }
+
+    public void testTwoSeriesDefinitions() throws Exception
+    {
+        createTestProperties(1, TEST_SERIES_1_SELECT_STATEMENT, TEST_SERIES_1_LEGEND, TEST_SERIES_1_DIR);
+        createTestProperties(2, TEST_SERIES_2_SELECT_STATEMENT, TEST_SERIES_2_LEGEND, TEST_SERIES_2_DIR);
+
+        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);
+        createTestProperties(3, TEST_SERIES_2_SELECT_STATEMENT, TEST_SERIES_2_LEGEND, TEST_SERIES_2_DIR);
+
+        List<SeriesDefinition> definitions = _seriesDefinitionLoader.createFromProperties(_properties);
+        assertEquals(1, definitions.size());
+    }
+
+    public void testSeriesDirectorySubstitution() throws Exception
+    {
+        final String tmpDir = System.getProperty("java.io.tmpdir");
+        createTestProperties(1, TEST_SERIES_1_SELECT_STATEMENT, TEST_SERIES_1_LEGEND, TEST_SERIES_1_DIR_WITH_SYSPROP);
+
+        List<SeriesDefinition> definitions = _seriesDefinitionLoader.createFromProperties(_properties);
+        assertEquals(1, definitions.size());
+
+        SeriesDefinition seriesDefinition1 = definitions.get(0);
+        assertTrue(seriesDefinition1.getSeriesDirectory().startsWith(tmpDir));
+    }
+
+    private void createTestProperties(int index, String selectStatement, String seriesLegend, String seriesDir) 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);
+    }
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...