SupportedEncodingsParser { public SupportedEncodings parseEncodings( DeegreeWMS jaxbConfig ) { SupportedRequests supportedRequests = jaxbConfig.getSupportedRequests(); if ( supportedRequests != null ) { if ( isAtLeastOneRequestTypeConfigured( supportedRequests ) || isGlobalSupportedEncodingsConfigured( supportedRequests ) ) return parseEncodings( supportedRequests ); } return new UnlimitedSupportedEncodings(); }  SupportedEncodings parseEncodings( DeegreeWMS jaxbConfig );  }
@Test public void testParseEncodingsWithRequestTypeSpecific() { DeegreeWMS deegreeWmsConfig = prepareSupportedRequestsWithRequestTypeSpecific(); LimitedSupportedEncodings limitedSupportedEncodings = (LimitedSupportedEncodings) webFeatureService.parseEncodings( deegreeWmsConfig ); Map<WMSRequestType, Set<String>> enabledEncodings = limitedSupportedEncodings.getEnabledEncodingsPerRequestType(); Set<String> getCapabilitiesEncodings = enabledEncodings.get( GetCapabilities ); assertThat( getCapabilitiesEncodings, hasOnlyItems( "xml", "soap" ) ); Set<String> describeLayerEncodings = enabledEncodings.get( DescribeLayer ); assertThat( describeLayerEncodings, hasOnlyItems( "xml" ) ); Set<String> getMapEncodings = enabledEncodings.get( GetMap ); assertThat( getMapEncodings, hasOnlyItems( "xml" ) ); Set<String> mapEncodings = enabledEncodings.get( map ); assertThat( mapEncodings, hasOnlyItems( "xml" ) ); Set<String> getFeatureInfoEncodings = enabledEncodings.get( GetFeatureInfo ); assertThat( getFeatureInfoEncodings.size(), is( 0 ) ); }
@Test public void testParseEncodingsWithKvpForAll() { DeegreeWMS deegreeWmsConfig = prepareSupportedRequestsWithKvpForAll(); LimitedSupportedEncodings limitedSupportedEncodings = (LimitedSupportedEncodings) webFeatureService.parseEncodings( deegreeWmsConfig ); Map<WMSRequestType, Set<String>> enabledEncodings = limitedSupportedEncodings.getEnabledEncodingsPerRequestType(); Set<String> getCapabilitiesEncodings = enabledEncodings.get( GetCapabilities ); assertThat( getCapabilitiesEncodings, hasOnlyItems( "kvp", "xml", "soap" ) ); Set<String> describeLayerEncodings = enabledEncodings.get( DescribeLayer ); assertThat( describeLayerEncodings, hasOnlyItems( "kvp", "xml" ) ); Set<String> getMapEncodings = enabledEncodings.get( GetMap ); assertThat( getMapEncodings, hasOnlyItems( "kvp", "xml" ) ); Set<String> mapEncodings = enabledEncodings.get( map ); assertThat( mapEncodings, hasOnlyItems( "kvp", "xml" ) ); Set<String> getFeatureInfoEncodings = enabledEncodings.get( GetFeatureInfo ); assertThat( getFeatureInfoEncodings.size(), is( 0 ) ); }
@Test public void testParseEncodingsWithKvpForAllAndNoRequestTypesSpecific() { DeegreeWMS deegreeWmsConfig = prepareSupportedRequestsWithKvpForAllAndNoRequestTypesSpecific(); LimitedSupportedEncodings limitedSupportedEncodings = (LimitedSupportedEncodings) webFeatureService.parseEncodings( deegreeWmsConfig ); Map<WMSRequestType, Set<String>> enabledEncodings = limitedSupportedEncodings.getEnabledEncodingsPerRequestType(); Set<String> getCapabilitiesEncodings = enabledEncodings.get( GetCapabilities ); assertThat( getCapabilitiesEncodings, hasOnlyItems( "kvp" ) ); Set<String> describeLayerEncodings = enabledEncodings.get( DescribeLayer ); assertThat( describeLayerEncodings, hasOnlyItems( "kvp" ) ); Set<String> getMapEncodings = enabledEncodings.get( GetMap ); assertThat( getMapEncodings, hasOnlyItems( "kvp" ) ); Set<String> mapEncodings = enabledEncodings.get( map ); assertThat( mapEncodings, hasOnlyItems( "kvp" ) ); Set<String> getFeatureInfoEncodings = enabledEncodings.get( GetFeatureInfo ); assertThat( getFeatureInfoEncodings, hasOnlyItems( "kvp" ) ); }
@Test public void testParseEncodingsWithKvpForAllAndEmptyRequestTypeSpecific() { DeegreeWMS deegreeWmsConfig = prepareSupportedRequestsWithKvpForAllAndEmptyRequestTypeSpecific(); LimitedSupportedEncodings limitedSupportedEncodings = (LimitedSupportedEncodings) webFeatureService.parseEncodings( deegreeWmsConfig ); Map<WMSRequestType, Set<String>> enabledEncodings = limitedSupportedEncodings.getEnabledEncodingsPerRequestType(); Set<String> getCapabilitiesEncodings = enabledEncodings.get( GetCapabilities ); assertThat( getCapabilitiesEncodings, hasOnlyItems( "kvp" ) ); assertThat( getCapabilitiesEncodings, not( hasOnlyItems( "xml", "soap" ) ) ); Set<String> describeLayerEncodings = enabledEncodings.get( DescribeLayer ); assertThat( describeLayerEncodings, hasOnlyItems( "kvp" ) ); assertThat( getCapabilitiesEncodings, not( hasOnlyItems( "xml", "soap" ) ) ); Set<String> getMapEncodings = enabledEncodings.get( GetMap ); assertThat( getMapEncodings.size(), is( 0 ) ); Set<String> mapEncodings = enabledEncodings.get( map ); assertThat( mapEncodings.size(), is( 0 ) ); Set<String> getFeatureInfoEncodings = enabledEncodings.get( GetFeatureInfo ); assertThat( getFeatureInfoEncodings.size(), is( 0 ) ); }
@Test public void testParseEncodingsWithEmptyAndSupportedRequestTypeSpecific() { DeegreeWMS deegreeWmsConfig = prepareSupportedRequestsWithEmptyAndSupportedRequestTypeSpecific(); LimitedSupportedEncodings limitedSupportedEncodings = (LimitedSupportedEncodings) webFeatureService.parseEncodings( deegreeWmsConfig ); Map<WMSRequestType, Set<String>> enabledEncodings = limitedSupportedEncodings.getEnabledEncodingsPerRequestType(); Set<String> getCapabilitiesEncodings = enabledEncodings.get( GetCapabilities ); assertThat( getCapabilitiesEncodings, hasOnlyItems( "xml", "soap" ) ); Set<String> describeLayerEncodings = enabledEncodings.get( DescribeLayer ); assertThat( describeLayerEncodings, hasOnlyItems( "xml", "soap", "kvp" ) ); Set<String> getMapEncodings = enabledEncodings.get( GetMap ); assertThat( getMapEncodings, hasOnlyItems( "xml" ) ); Set<String> mapEncodings = enabledEncodings.get( map ); assertThat( mapEncodings, hasOnlyItems( "xml" ) ); Set<String> getFeatureInfoEncodings = enabledEncodings.get( GetFeatureInfo ); assertThat( getFeatureInfoEncodings.size(), is( 0 ) ); }
@Test public void testParseEncodingsWithEmptyRequestTypesSpecific() { DeegreeWMS deegreeWmsConfig = prepareSupportedRequestsWithEmptyRequestTypesSpecific(); LimitedSupportedEncodings limitedSupportedEncodings = (LimitedSupportedEncodings) webFeatureService.parseEncodings( deegreeWmsConfig ); Map<WMSRequestType, Set<String>> enabledEncodings = limitedSupportedEncodings.getEnabledEncodingsPerRequestType(); Set<String> getCapabilitiesEncodings = enabledEncodings.get( GetCapabilities ); assertThat( getCapabilitiesEncodings, hasOnlyItems( "kvp", "xml", "soap" ) ); Set<String> getMapEncodings = enabledEncodings.get( GetMap ); assertThat( getMapEncodings, hasOnlyItems( "kvp", "xml", "soap" ) ); Set<String> mapEncodings = enabledEncodings.get( map ); assertThat( mapEncodings, hasOnlyItems( "kvp", "xml", "soap" ) ); Set<String> describeLayerEncodings = enabledEncodings.get( DescribeLayer ); assertThat( describeLayerEncodings.size(), is( 0 ) ); Set<String> getFeatureInfoEncodings = enabledEncodings.get( GetFeatureInfo ); assertThat( getFeatureInfoEncodings.size(), is( 0 ) ); }
@Test public void testParseEncodingsWithoutRequestTypesSpecificAndKvp() { DeegreeWMS deegreeWmsConfig = prepareSupportedRequestsWithoutRequestTypesSpecificAndKvp(); SupportedEncodings unlimitedSupportedEncodings = webFeatureService.parseEncodings( deegreeWmsConfig ); assertThat( unlimitedSupportedEncodings, CoreMatchers.instanceOf( UnlimitedSupportedEncodings.class ) ); }
@Test public void testParseEncodingsWithoutSupportedRequestConfiguration() { DeegreeWMS deegreeWmsConfig = prepareSupportedRequestsWithoutSupportedRequestConfiguration(); SupportedEncodings unlimitedSupportedEncodings = webFeatureService.parseEncodings( deegreeWmsConfig ); assertThat( unlimitedSupportedEncodings, CoreMatchers.instanceOf( UnlimitedSupportedEncodings.class ) ); }