WFSDataStore wfs = getWFSDataStore(new TestHttpClient() {
@Override
public HTTPResponse get(URL url) throws IOException {
if (url.getQuery().contains("REQUEST=GetCapabilities")) {
return new TestHttpResponse(TestData.getResource(this, "MapServer/GetCapabilities_1_1_0.xml"), "text/xml");
} else {
return new TestHttpResponse(TestData.getResource(this, "MapServer/GetFeature_GovernmentalUnitCE.xml"), "text/xml");
}
}
@Override
public HTTPResponse post(URL url, InputStream postContent, String postContentType) throws IOException {
String request = new String(IOUtils.toByteArray(postContent), "UTF-8");
if (request.contains("<wfs:DescribeFeatureType"))
{
return new TestHttpResponse(TestData.getResource(this, "MapServer/DescribeFeatureType_GovernmentalUnitCE.xsd"), "text/xml");
} else {
return new TestHttpResponse(TestData.getResource(this, "MapServer/GetFeature_GovernmentalUnitCE.xml"), "text/xml");
}
}
});
SimpleFeatureSource source = wfs.getFeatureSource(new NameImpl("http://mapserver.gis.umn.edu/mapserver", "ms_GovernmentalUnitCE"));