48 lines
2.1 KiB
Java
48 lines
2.1 KiB
Java
|
|
import net.sf.jasperreports.engine.*;
|
||
|
|
import net.sf.jasperreports.engine.design.*;
|
||
|
|
import net.sf.jasperreports.engine.xml.*;
|
||
|
|
import java.io.*;
|
||
|
|
|
||
|
|
public class JrxmlDebug {
|
||
|
|
public static void main(String[] args) throws Exception {
|
||
|
|
String path = args.length > 0 ? args[0] : "D:/Idea Project/jaspersoft/tmp/test_simple.jrxml";
|
||
|
|
File f = new File(path);
|
||
|
|
System.out.println("File: " + path + " (exists=" + f.exists() + ", len=" + f.length() + ")");
|
||
|
|
|
||
|
|
// Test 1: JRXmlLoader.load()
|
||
|
|
System.out.println("\n=== JRXmlLoader.load() ===");
|
||
|
|
try {
|
||
|
|
JasperDesign design = JRXmlLoader.load(f);
|
||
|
|
System.out.println("PASS: " + design.getName()
|
||
|
|
+ " pages=" + design.getPageWidth() + "x" + design.getPageHeight());
|
||
|
|
System.out.println(" Title: " + (design.getTitle() != null ? design.getTitle().getHeight() + "px" : "null"));
|
||
|
|
System.out.println(" Detail: " + (design.getDetailSection() != null ? "present" : "null"));
|
||
|
|
} catch (Throwable t) {
|
||
|
|
System.out.println("FAIL: " + t.getMessage());
|
||
|
|
Throwable c = t;
|
||
|
|
int d = 0;
|
||
|
|
while (c != null) {
|
||
|
|
System.out.println(" [" + d + "] " + c.getClass().getName() + ": " + c.getMessage());
|
||
|
|
for (int i = 0; i < Math.min(5, c.getStackTrace().length); i++)
|
||
|
|
System.out.println(" at " + c.getStackTrace()[i]);
|
||
|
|
c = c.getCause();
|
||
|
|
d++;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Test 2: JasperCompileManager.compileReport()
|
||
|
|
System.out.println("\n=== JasperCompileManager.compileReport() ===");
|
||
|
|
try {
|
||
|
|
JasperReport report = JasperCompileManager.compileReport(path);
|
||
|
|
System.out.println("PASS: " + report.getName());
|
||
|
|
} catch (Throwable t) {
|
||
|
|
System.out.println("FAIL: " + t.getMessage());
|
||
|
|
Throwable c = t;
|
||
|
|
while (c != null) {
|
||
|
|
System.out.println(" -> " + c.getClass().getName() + ": " + c.getMessage());
|
||
|
|
c = c.getCause();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|