details:   https://code.openbravo.com/erp/devel/pi/rev/d3de567925ce
changeset: 28258:d3de567925ce
user:      Asier Lostalé <asier.lostale <at> openbravo.com>
date:      Thu Jan 14 12:25:27 2016 +0100
summary:   related to bug 31709: added test case

  The original problem was reproducible whenever the jrxml contained a 
String.replace.
  Added a test case covering it.

diffstat:

 src-test/src/org/openbravo/test/AllAntTaskTests.java                    |   8 
+-
 src-test/src/org/openbravo/test/reporting/JasperReportsCompilation.java |  69 
++++++++++
 2 files changed, 75 insertions(+), 2 deletions(-)

diffs (105 lines):

diff -r e913a860b967 -r d3de567925ce 
src-test/src/org/openbravo/test/AllAntTaskTests.java
--- a/src-test/src/org/openbravo/test/AllAntTaskTests.java      Thu Jan 14 
10:49:51 2016 +0100
+++ b/src-test/src/org/openbravo/test/AllAntTaskTests.java      Thu Jan 14 
12:25:27 2016 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2009-2015 Openbravo SLU 
+ * All portions are Copyright (C) 2009-2016 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -71,6 +71,7 @@
 import org.openbravo.test.modularity.ModuleScriptsVersions;
 import org.openbravo.test.modularity.TableNameTest;
 import org.openbravo.test.preference.PreferenceTest;
+import org.openbravo.test.reporting.JasperReportsCompilation;
 import org.openbravo.test.role.inheritance.RoleInheritanceTestSuite;
 import org.openbravo.test.scheduling.ProcessSchedulingTest;
 import org.openbravo.test.security.AccessLevelTest;
@@ -217,7 +218,10 @@
     // grid configuration
     ViewGenerationWithDifferentConfigLevelTest.class, //
     GCSequenceNumberTests.class, //
-    SortingFilteringGridConfiguration.class
+    SortingFilteringGridConfiguration.class,
+
+    // jasper
+    JasperReportsCompilation.class
 
 })
 public class AllAntTaskTests {
diff -r e913a860b967 -r d3de567925ce 
src-test/src/org/openbravo/test/reporting/JasperReportsCompilation.java
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/src/org/openbravo/test/reporting/JasperReportsCompilation.java   
Thu Jan 14 12:25:27 2016 +0100
@@ -0,0 +1,69 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2015 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.test.reporting;
+
+import java.io.IOException;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.Test;
+
+import net.sf.jasperreports.engine.JRException;
+import net.sf.jasperreports.engine.JasperCompileManager;
+import net.sf.jasperreports.engine.JasperReport;
+import net.sf.jasperreports.engine.design.JasperDesign;
+import net.sf.jasperreports.engine.xml.JRXmlLoader;
+
+/**
+ * Test cases covering the jrxml compilation.
+ * 
+ * @author alostale
+ *
+ */
+public class JasperReportsCompilation {
+  /**
+   * Compiles a jrxml which includes a String.replace. This case was failing 
using JDK8 with
+   * jdt-compiler-3.1.1.jar. Before fixing the issue, this test case failed 
with an exception.
+   * 
+   * See issue #31709
+   */
+  @Test
+  public void jrxmlShouldBeCompiledWithAllSupportedJDKs() throws JRException, 
IOException {
+    String jrxml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" //
+        + "<jasperReport bottomMargin=\"20\" columnWidth=\"535\" 
leftMargin=\"30\" name=\"ReportTrialBalancePDF\" pageHeight=\"842\" 
pageWidth=\"595\" rightMargin=\"30\" topMargin=\"20\" 
uuid=\"94f73212-0a4e-4d01-a77d-7c1011919e14\"\n" //
+        + "  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"; 
xmlns=\"http://jasperreports.sourceforge.net/jasperreports\"; 
xsi:schemaLocation=\"http://jasperreports.sourceforge.net/jasperreports 
http://jasperreports.sourceforge.net/xsd/jasperreport.xsd\";>\n" //
+        + "  <import value=\"net.sf.jasperreports.engine.*\"/>\n" //
+        + "  <import value=\"java.util.*\"/>\n" //
+        + "\n" //
+        + "  <pageFooter>\n" //
+        + "    <band height=\"40\">\n" //
+        + "      <textField>\n" //
+        + "        <reportElement height=\"16\" width=\"257\" x=\"245\" 
y=\"15\"/>\n" //
+
+        // this was the problematic instruction
+        + "        
<textFieldExpression><![CDATA[\"xx\".replace(\"x\",\"1\")]]></textFieldExpression>\n"
 //
+
+        + "      </textField>\n" //
+        + "    </band>\n" //
+        + "  </pageFooter>\n" //
+        + "</jasperReport>";
+    JasperDesign jasperDesign = JRXmlLoader.load(IOUtils.toInputStream(jrxml, 
"UTF-8"));
+    @SuppressWarnings("unused")
+    JasperReport jasperReport = 
JasperCompileManager.compileReport(jasperDesign);
+  }
+}

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to