GetFeatureInfoParser extends AbstractWmsParser { public GetFeatureInfo parse( XMLStreamReader getMap ) throws OWSException, XMLStreamException { Version version = forwardToStartAndDetermineVersion( getMap ); if ( !WMSConstants.VERSION_130.equals( version ) ) throw new InvalidParameterException( "Version " + version + " is not supported (yet)." ); try { return parse130( getMap ); } catch ( UnknownCRSException e ) { throw new OWSException( e.getMessage(), OWSException.NO_APPLICABLE_CODE ); } catch ( ParseException e ) { throw new OWSException( e.getMessage(), OWSException.NO_APPLICABLE_CODE ); } }  GetFeatureInfo parse( XMLStreamReader getMap );  }
@Test public void testParse() throws Exception { GetFeatureInfoParser parser = new GetFeatureInfoParser(); XMLStreamReader xmlStreamReader = createXmlStreamReader( "wms-1.3.0-GetFeatureInfo.xml" ); GetFeatureInfo getFeatureInfo = parser.parse( xmlStreamReader ); assertThat( getFeatureInfo.getWidth(), is( 1024 ) ); assertThat( getFeatureInfo.getHeight(), is( 512 ) ); assertThat( getFeatureInfo.getCoordinateSystem(), is( CRSManager.lookup( "EPSG:4326" ) ) ); Envelope boundingBox = getFeatureInfo.getEnvelope(); assertThat( boundingBox.getMin().get0(), is( -115.4 ) ); assertThat( boundingBox.getMin().get1(), is( 35.0 ) ); assertThat( boundingBox.getMax().get0(), is( -108.0 ) ); assertThat( boundingBox.getMax().get1(), is( 44.0 ) ); HashMap<String, List<?>> dimensions = getFeatureInfo.getDimensions(); assertThat( dimensions.size(), is( 0 ) ); Map<String, String> parameterMap = getFeatureInfo.getParameterMap(); assertThat( parameterMap.size(), is( 1 ) ); assertThat( parameterMap.get( "EXCEPTIONS" ), is( "XML" ) ); assertThat( getFeatureInfo.getX(), is( 5 ) ); assertThat( getFeatureInfo.getY(), is( 10 ) ); assertThat( getFeatureInfo.getFeatureCount(), is( 42 ) ); assertThat( getFeatureInfo.getInfoFormat(), is( "text/html" ) ); assertThat( getFeatureInfo.getQueryLayers().size(), is( 2 ) ); assertThat( getFeatureInfo.getQueryLayers(), hasLayerRef( "counties" ) ); assertThat( getFeatureInfo.getQueryLayers(), hasLayerRef( "municipalities" ) ); }
@Test public void testParse_defaultValues() throws Exception { GetFeatureInfoParser parser = new GetFeatureInfoParser(); XMLStreamReader xmlStreamReader = createXmlStreamReader( "wms-1.3.0-GetFeatureInfo_simple.xml" ); GetFeatureInfo getFeatureInfo = parser.parse( xmlStreamReader ); Map<String, String> parameterMap = getFeatureInfo.getParameterMap(); assertThat( parameterMap.size(), is( 0 ) ); assertThat( getFeatureInfo.getX(), is( 50 ) ); assertThat( getFeatureInfo.getY(), is( 15 ) ); assertThat( getFeatureInfo.getFeatureCount(), is( 1 ) ); assertThat( getFeatureInfo.getInfoFormat(), is( "text/xml" ) ); assertThat( getFeatureInfo.getQueryLayers().size(), is( 1 ) ); assertThat( getFeatureInfo.getQueryLayers(), hasLayerRef( "counties" ) ); }