*
* @throws Exception
*/
@SuppressWarnings("unchecked")
public void testProxyBaseURL() throws Exception {
GeoServer gs = getGeoServer();
try {
GeoServerInfo info = gs.getGlobal();
info.setProxyBaseUrl("http://myhost:9999/gs");
gs.save(info);
MapLayer mapLayer = createMapLayer(MockData.POINTS, "Bridge");
FeatureSource<SimpleFeatureType, SimpleFeature> featureSource;
featureSource = (FeatureSource<SimpleFeatureType, SimpleFeature>) mapLayer
.getFeatureSource();
int nfeatures = featureSource.getFeatures().size();
WMSMapContext mapContext = new WMSMapContext(createGetMapRequest(MockData.POINTS));
Document document;
try {
mapContext.addLayer(mapLayer);
KMLVectorTransformer transformer = new KMLVectorTransformer(getWMS(), mapContext,
mapLayer);
transformer.setIndentation(2);
document = WMSTestSupport.transform(featureSource.getFeatures(), transformer);
// print(document);
} finally {
mapContext.dispose();
}
// make sure we are using the proxy base URL
XMLAssert.assertXpathEvaluatesTo("http://myhost:9999/gs/styles/bridge.png",
"//Style/IconStyle/Icon/href", document);
} finally {
GeoServerInfo info = gs.getGlobal();
info.setProxyBaseUrl(null);
gs.save(info);
}
}