01: package org.geoserver.wfs.v1_1;
02:
03: import java.io.ByteArrayInputStream;
04: import java.io.ByteArrayOutputStream;
05: import java.io.InputStreamReader;
06: import java.net.URL;
07: import java.net.URLConnection;
08: import java.util.logging.Level;
09: import java.util.logging.Logger;
10:
11: import net.opengis.wfs.GetCapabilitiesType;
12: import net.opengis.wfs.WfsFactory;
13:
14: import org.geoserver.util.ErrorHandler;
15: import org.geoserver.util.ReaderUtils;
16: import org.geoserver.wfs.CapabilitiesTransformer;
17: import org.geoserver.wfs.WFSTestSupport;
18: import org.geoserver.wfs.xml.v1_1_0.WFS;
19:
20: public class CapabilitiesTransformerTest extends WFSTestSupport {
21:
22: static Logger logger = org.geotools.util.logging.Logging
23: .getLogger("org.geoserver.wfs.test");
24:
25: GetCapabilitiesType request() {
26: GetCapabilitiesType type = WfsFactory.eINSTANCE
27: .createGetCapabilitiesType();
28: type.setBaseUrl("http://localhost:8080/geoserver");
29: return type;
30: }
31:
32: public void test() throws Exception {
33: CapabilitiesTransformer tx = new CapabilitiesTransformer.WFS1_1(
34: getWFS(), getCatalog());
35: ByteArrayOutputStream output = new ByteArrayOutputStream();
36: tx.transform(request(), output);
37:
38: InputStreamReader reader = new InputStreamReader(
39: new ByteArrayInputStream(output.toByteArray()));
40:
41: ErrorHandler handler = new ErrorHandler(logger, Level.WARNING);
42: ReaderUtils.validate(reader, handler, WFS.NAMESPACE,
43: "http://schemas.opengis.net/wfs/1.1.0/wfs.xsd");
44:
45: //only check for no errors if online
46: try {
47:
48: URLConnection c = new URL(
49: "http://schemas.opengis.net/wfs/1.1.0/wfs.xsd")
50: .openConnection();
51: c.getInputStream().read();
52:
53: assertTrue(handler.errors.isEmpty());
54: } catch (Exception e) {
55: }
56:
57: }
58: }
|