@Test public void testRecognizeReflexiveUserAliases() { aliases.setValue("foo bar baz"); WFSURIHandler.init(strategy); WFSURIHandler handler = new WFSURIHandler(gs); final URI wrongHost = URI.createURI( "http://example.com/geoserver/wfs?service=wfs&version=2.0.0&request=DescribeFeatureType"); final URI notDFT = URI.createURI("http://foo/geoserver/wfs?service=wfs&version=2.0.0&request=GetCapabilities"); final URI fooDFT = URI.createURI( "http://foo/geoserver/wfs?service=wfs&version=2.0.0&request=DescribeFeatureType"); final URI barDFT = URI.createURI( "http://bar/geoserver/wfs?service=wfs&version=2.0.0&request=DescribeFeatureType"); final URI bazDFT = URI.createURI( "http://baz/geoserver/wfs?service=wfs&version=2.0.0&request=DescribeFeatureType"); final URI localhostDFT = URI.createURI( "http://localhost/geoserver/wfs?service=wfs&version=2.0.0&request=DescribeFeatureType"); assertThat(handler.canHandle(wrongHost), is(false)); assertThat(handler.canHandle(notDFT), is(false)); assertThat(handler.canHandle(fooDFT), is(true)); assertThat(handler.canHandle(barDFT), is(true)); assertThat(handler.canHandle(bazDFT), is(true)); assertThat(handler.canHandle(localhostDFT), is(false)); }
@Test public void testDefaultAliases() { WFSURIHandler.init(strategy); assertThat(WFSURIHandler.ADDRESSES, empty()); assertThat(WFSURIHandler.ADDITIONAL_HOSTNAMES, contains("localhost")); }
@Test public void testOverrideAliasesSpace() { aliases.setValue("foo bar baz "); WFSURIHandler.init(strategy); assertThat(WFSURIHandler.ADDRESSES, empty()); assertThat(WFSURIHandler.ADDITIONAL_HOSTNAMES, containsInAnyOrder("foo", "bar", "baz")); }
@Test public void testRecognizeReflexiveSimple() { WFSURIHandler.init(strategy); WFSURIHandler handler = new WFSURIHandler(gs); final URI wrongHost = URI.createURI( "http://example.com/geoserver/wfs?service=wfs&version=2.0.0&request=DescribeFeatureType"); final URI notDFT = URI.createURI( "http://localhost/geoserver/wfs?service=wfs&version=2.0.0&request=GetCapabilities"); final URI localDFT = URI.createURI( "http://localhost/geoserver/wfs?service=wfs&version=2.0.0&request=DescribeFeatureType"); assertThat(handler.canHandle(wrongHost), is(false)); assertThat(handler.canHandle(notDFT), is(false)); assertThat(handler.canHandle(localDFT), is(true)); }