Workaround jasper report test fail on OSX
Add temporary Assume.canLoadNativeDirFonts() method allowing failing jasper report tests to be bypassed on OSX. This should be revisited when JDK 8 is released. Issue: SPR-10537
This commit is contained in:
@@ -16,13 +16,17 @@
|
||||
|
||||
package org.springframework.web.servlet.view.jasperreports;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
*/
|
||||
public abstract class AbstractConfigurableJasperReportsViewTests extends AbstractJasperReportsViewTests {
|
||||
|
||||
@Test
|
||||
public void testNoConfiguredExporter() throws Exception {
|
||||
ConfigurableJasperReportsView view = new ConfigurableJasperReportsView();
|
||||
view.setUrl(COMPILED_REPORT);
|
||||
|
||||
@@ -22,11 +22,13 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.springframework.mock.web.test.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.test.MockHttpServletResponse;
|
||||
import org.springframework.tests.Assume;
|
||||
import org.springframework.ui.jasperreports.PersonBean;
|
||||
import org.springframework.ui.jasperreports.ProductBean;
|
||||
import org.springframework.util.ClassUtils;
|
||||
@@ -37,7 +39,7 @@ import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public abstract class AbstractJasperReportsTests extends TestCase {
|
||||
public abstract class AbstractJasperReportsTests {
|
||||
|
||||
protected static final String COMPILED_REPORT = "/org/springframework/ui/jasperreports/DataSourceReport.jasper";
|
||||
|
||||
@@ -54,7 +56,12 @@ public abstract class AbstractJasperReportsTests extends TestCase {
|
||||
protected MockHttpServletResponse response;
|
||||
|
||||
|
||||
@Override
|
||||
@BeforeClass
|
||||
public static void assumptions() {
|
||||
Assume.canLoadNativeDirFonts();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
request = new MockHttpServletRequest();
|
||||
response = new MockHttpServletResponse();
|
||||
|
||||
@@ -34,12 +34,14 @@ import net.sf.jasperreports.engine.data.JRAbstractBeanDataSourceProvider;
|
||||
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.ApplicationContextException;
|
||||
import org.springframework.mock.web.test.MockServletContext;
|
||||
import org.springframework.ui.jasperreports.PersonBean;
|
||||
import org.springframework.web.context.support.StaticWebApplicationContext;
|
||||
import org.springframework.web.servlet.DispatcherServlet;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.BDDMockito.*;
|
||||
|
||||
/**
|
||||
@@ -63,6 +65,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
/**
|
||||
* Simple test to see if compiled report succeeds.
|
||||
*/
|
||||
@Test
|
||||
public void testCompiledReport() throws Exception {
|
||||
AbstractJasperReportsView view = getView(COMPILED_REPORT);
|
||||
view.render(getModel(), request, response);
|
||||
@@ -74,6 +77,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUncompiledReport() throws Exception {
|
||||
if (!canCompileReport) {
|
||||
return;
|
||||
@@ -84,6 +88,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
assertTrue(response.getContentAsByteArray().length > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithInvalidPath() throws Exception {
|
||||
try {
|
||||
getView("foo.jasper");
|
||||
@@ -94,6 +99,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidExtension() throws Exception {
|
||||
try {
|
||||
getView("foo.bar");
|
||||
@@ -104,12 +110,14 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testContentType() throws Exception {
|
||||
AbstractJasperReportsView view = getView(COMPILED_REPORT);
|
||||
view.render(getModel(), request, response);
|
||||
assertEquals("Response content type is incorrect", getDesiredContentType(), response.getContentType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithoutDatasource() throws Exception {
|
||||
Map model = getModel();
|
||||
model.remove("dataSource");
|
||||
@@ -118,6 +126,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
assertTrue(response.getStatus() == HttpServletResponse.SC_OK);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithCollection() throws Exception {
|
||||
Map model = getModel();
|
||||
model.remove("dataSource");
|
||||
@@ -127,6 +136,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
assertTrue(response.getContentAsByteArray().length > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithMultipleCollections() throws Exception {
|
||||
Map model = getModel();
|
||||
model.remove("dataSource");
|
||||
@@ -137,6 +147,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
// no clear data source found
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithJRDataSourceProvider() throws Exception {
|
||||
Map model = getModel();
|
||||
model.remove("dataSource");
|
||||
@@ -146,6 +157,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
assertTrue(response.getContentAsByteArray().length > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithSpecificCollection() throws Exception {
|
||||
Map model = getModel();
|
||||
model.remove("dataSource");
|
||||
@@ -157,6 +169,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
assertTrue(response.getContentAsByteArray().length > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithArray() throws Exception {
|
||||
Map model = getModel();
|
||||
model.remove("dataSource");
|
||||
@@ -166,6 +179,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
assertTrue(response.getContentAsByteArray().length > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithMultipleArrays() throws Exception {
|
||||
Map model = getModel();
|
||||
model.remove("dataSource");
|
||||
@@ -176,6 +190,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
// no clear data source found
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithSpecificArray() throws Exception {
|
||||
Map model = getModel();
|
||||
model.remove("dataSource");
|
||||
@@ -187,6 +202,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
assertTrue(response.getContentAsByteArray().length > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithSubReport() throws Exception {
|
||||
if (!canCompileReport) {
|
||||
return;
|
||||
@@ -208,6 +224,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
assertTrue(response.getContentAsByteArray().length > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithNonExistentSubReport() throws Exception {
|
||||
if (!canCompileReport) {
|
||||
return;
|
||||
@@ -258,6 +275,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
assertEquals(overiddenCharacterEncoding, this.response.getCharacterEncoding());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubReportWithUnspecifiedParentDataSource() throws Exception {
|
||||
if (!canCompileReport) {
|
||||
return;
|
||||
@@ -282,6 +300,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testContentDisposition() throws Exception {
|
||||
AbstractJasperReportsView view = getView(COMPILED_REPORT);
|
||||
view.render(getModel(), request, response);
|
||||
@@ -289,6 +308,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOverrideContentDisposition() throws Exception {
|
||||
Properties headers = new Properties();
|
||||
String cd = "attachment";
|
||||
@@ -300,6 +320,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
assertEquals("Invalid content type", cd, response.getHeader("Content-Disposition"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetCustomHeaders() throws Exception {
|
||||
Properties headers = new Properties();
|
||||
|
||||
@@ -316,6 +337,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
assertEquals("Invalid header value", value, response.getHeader(key));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithJdbcDataSource() throws Exception {
|
||||
if (!canCompileReport) {
|
||||
return;
|
||||
@@ -336,6 +358,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithJdbcDataSourceInModel() throws Exception {
|
||||
if (!canCompileReport) {
|
||||
return;
|
||||
@@ -356,6 +379,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJRDataSourceOverridesJdbcDataSource() throws Exception {
|
||||
if (!canCompileReport) {
|
||||
return;
|
||||
@@ -378,6 +402,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor
|
||||
return ds;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithCharacterEncoding() throws Exception {
|
||||
AbstractJasperReportsView view = getView(COMPILED_REPORT);
|
||||
|
||||
|
||||
@@ -27,15 +27,19 @@ import net.sf.jasperreports.engine.JRExporterParameter;
|
||||
import net.sf.jasperreports.engine.JasperPrint;
|
||||
import net.sf.jasperreports.engine.export.JRHtmlExporterParameter;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.mock.web.test.MockServletContext;
|
||||
import org.springframework.web.context.support.StaticWebApplicationContext;
|
||||
import org.springframework.web.servlet.DispatcherServlet;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
*/
|
||||
public class ExporterParameterTests extends AbstractJasperReportsTests {
|
||||
|
||||
@Test
|
||||
public void testParameterParsing() throws Exception {
|
||||
Map params = new HashMap();
|
||||
params.put("net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IMAGES_URI", "/foo/bar");
|
||||
@@ -84,6 +88,7 @@ public class ExporterParameterTests extends AbstractJasperReportsTests {
|
||||
view.render(getModel(), request, response);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidClass() throws Exception {
|
||||
Map params = new HashMap();
|
||||
params.put("foo.net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IMAGES_URI", "/foo");
|
||||
@@ -101,6 +106,7 @@ public class ExporterParameterTests extends AbstractJasperReportsTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidField() {
|
||||
Map params = new HashMap();
|
||||
params.put("net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IMAGES_URI_FOO", "/foo");
|
||||
@@ -118,6 +124,7 @@ public class ExporterParameterTests extends AbstractJasperReportsTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidType() {
|
||||
Map params = new HashMap();
|
||||
params.put("java.lang.Boolean.TRUE", "/foo");
|
||||
@@ -136,6 +143,7 @@ public class ExporterParameterTests extends AbstractJasperReportsTests {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testTypeConversion() {
|
||||
Map params = new HashMap();
|
||||
params.put("net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN", "true");
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.web.servlet.view.jasperreports;
|
||||
|
||||
import net.sf.jasperreports.engine.export.JRHtmlExporterParameter;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReader;
|
||||
import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
@@ -25,6 +26,8 @@ import org.springframework.mock.web.test.MockServletContext;
|
||||
import org.springframework.web.context.support.GenericWebApplicationContext;
|
||||
import org.springframework.web.servlet.DispatcherServlet;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
*/
|
||||
@@ -40,6 +43,7 @@ public class JasperReportsHtmlViewTests extends AbstractJasperReportsViewTests {
|
||||
return "text/html";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfigureExporterParametersWithEncodingFromPropertiesFile() throws Exception {
|
||||
GenericWebApplicationContext ac = new GenericWebApplicationContext();
|
||||
ac.setServletContext(new MockServletContext());
|
||||
|
||||
@@ -19,10 +19,15 @@ package org.springframework.web.servlet.view.jasperreports;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import net.sf.jasperreports.engine.JasperPrint;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
@@ -34,6 +39,7 @@ public class JasperReportsMultiFormatViewTests extends AbstractJasperReportsView
|
||||
model.put(getDiscriminatorKey(), "csv");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleHtmlRender() throws Exception {
|
||||
if (!canCompileReport) {
|
||||
return;
|
||||
@@ -50,6 +56,7 @@ public class JasperReportsMultiFormatViewTests extends AbstractJasperReportsView
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void testOverrideContentDisposition() throws Exception {
|
||||
if (!canCompileReport) {
|
||||
return;
|
||||
@@ -73,6 +80,7 @@ public class JasperReportsMultiFormatViewTests extends AbstractJasperReportsView
|
||||
response.getHeader("Content-Disposition"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExporterParametersAreCarriedAcross() throws Exception {
|
||||
if (!canCompileReport) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user