01: package org.geoserver.wfs.response;
02:
03: import java.io.ByteArrayInputStream;
04: import java.io.ByteArrayOutputStream;
05: import java.util.Arrays;
06: import java.util.HashSet;
07: import java.util.Set;
08: import java.util.zip.ZipEntry;
09: import java.util.zip.ZipInputStream;
10:
11: import net.opengis.wfs.FeatureCollectionType;
12: import net.opengis.wfs.WfsFactory;
13:
14: import org.geoserver.data.test.MockData;
15: import org.geoserver.wfs.WFSTestSupport;
16: import org.geotools.data.FeatureSource;
17:
18: public class ShapeZipTest extends WFSTestSupport {
19:
20: public void testNoNativeProjection() throws Exception {
21: FeatureSource fs = getCatalog().getFeatureTypeInfo(
22: MockData.BASIC_POLYGONS).getFeatureSource(true);
23: ShapeZipOutputFormat zip = new ShapeZipOutputFormat();
24: ByteArrayOutputStream bos = new ByteArrayOutputStream();
25: FeatureCollectionType fct = WfsFactory.eINSTANCE
26: .createFeatureCollectionType();
27: fct.getFeature().add(fs.getFeatures());
28: zip.write(fct, bos, null);
29:
30: ZipInputStream zis = new ZipInputStream(
31: new ByteArrayInputStream(bos.toByteArray()));
32: ZipEntry entry = null;
33: Set names = new HashSet(Arrays.asList(new String[] { ".shp",
34: ".shx", ".dbf", ".prj" }));
35: while ((entry = zis.getNextEntry()) != null) {
36: final String name = entry.getName();
37: final String extension = name.substring(name.length() - 4,
38: name.length());
39: assertTrue(names.contains(extension));
40: names.remove(extension);
41: zis.closeEntry();
42: }
43: zis.close();
44:
45: }
46: }
|