public class CSVOutputFormatTest extends WFSTestSupport {
public void testFullRequest() throws Exception {
MockHttpServletResponse resp = getAsServletResponse("wfs?request=GetFeature&typeName=sf:PrimitiveGeoFeature&outputFormat=csv");
FeatureSource fs = getFeatureSource(MockData.PRIMITIVEGEOFEATURE);
// System.out.println(resp.getOutputStreamContent());
// check the mime type
assertEquals("text/csv", resp.getContentType());
// check the content disposition
assertEquals("attachment; filename=PrimitiveGeoFeature.csv", resp.getHeader("Content-Disposition"));
// read the response back with a parser that can handle escaping, newlines and what not
List<String[]> lines = readLines(resp.getOutputStreamContent());
// we should have one header line and then all the features in that feature type
assertEquals(fs.getCount(Query.ALL) + 1, lines.size());
for (String[] line : lines) {
// check each line has the expected number of elements (num of att + 1 for the id)
assertEquals(fs.getSchema().getDescriptors().size() + 1, line.length);
}
}