From 6d6492b1f0c7c2090f2a78ecd9307f7543d03ff8 Mon Sep 17 00:00:00 2001 From: Philip Luppens Date: Sat, 8 Sep 2007 22:46:02 +0000 Subject: [PATCH] Fixed class to pass unit test. Don't really like the solution, but for now it should work. git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@573921 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/struts2/dispatcher/ChartResult.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/jfreechart/src/main/java/org/apache/struts2/dispatcher/ChartResult.java b/plugins/jfreechart/src/main/java/org/apache/struts2/dispatcher/ChartResult.java index 27cf6f907..65a5d1a01 100644 --- a/plugins/jfreechart/src/main/java/org/apache/struts2/dispatcher/ChartResult.java +++ b/plugins/jfreechart/src/main/java/org/apache/struts2/dispatcher/ChartResult.java @@ -103,6 +103,7 @@ public class ChartResult implements Result { private static final String DEFAULT_VALUE = "chart"; private JFreeChart chart; // the JFreeChart to render + private boolean chartSet; Integer height, width; String type = DEFAULT_TYPE; // supported are jpg, jpeg or png, defaults to png String value = DEFAULT_VALUE; // defaults to 'chart' @@ -158,6 +159,7 @@ public class ChartResult implements Result { } public void setChart(JFreeChart chart) { + this.chartSet = true; this.chart = chart; } @@ -172,7 +174,7 @@ public class ChartResult implements Result { * @throws Exception if an error occurs when creating or writing the chart to the servlet output stream. */ public void execute(ActionInvocation invocation) throws Exception { - if (chart == null) + if (!chartSet) // if our chart hasn't been set (by the testcase), we'll look it up in the value stack chart = (JFreeChart) invocation.getStack().findValue(value, JFreeChart.class); if (chart == null) // we need to have a chart object - if not, blow up throw new NullPointerException("No JFreeChart object found on the stack with name " + value);