diff options
| author | Alex Rudyy <orudyy@apache.org> | 2015-04-15 09:47:28 +0000 |
|---|---|---|
| committer | Alex Rudyy <orudyy@apache.org> | 2015-04-15 09:47:28 +0000 |
| commit | 0a0baee45ebcff44635907d457c4ff6810b09c87 (patch) | |
| tree | 8bfb0f9eddbc23cff88af69be80ab3ce7d47011c /qpid/java/perftests/visualisation-jfc/src/test | |
| parent | 54aa3d7070da16ce55c28ccad3f7d0871479e461 (diff) | |
| download | qpid-python-0a0baee45ebcff44635907d457c4ff6810b09c87.tar.gz | |
QPID-6481: Move java source tree to top level
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1673693 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/perftests/visualisation-jfc/src/test')
12 files changed, 0 insertions, 1259 deletions
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 |
