WFSGetDomain { public Set<String> getDomainValuesAsStrings(WFSService service, String attribute) throws IOException { Set<String> domain = new HashSet<>(); URL getCapsUrl = WFSDataStoreFactory.createGetCapabilitiesRequest(new URL(service.getEndpoint()), Version.v1_1_0); log.debug("Getting domains from wfs at " + getCapsUrl); Map params = new HashMap<>(); params.put(WFSDataStoreFactory.URL.key, getCapsUrl); params.put(WFSDataStoreFactory.TIMEOUT.key, TIMEOUT_MILLISECONDS); WFSDataStore wfs = datastore.createDataStore(params); if (wfs == null) { log.debug("Could not set up WFS datastore"); throw new WFSException("Could not set up WFS datastore"); } try { Query query = new Query(service.getTypeName(), Filter.INCLUDE, new String[] {attribute}); SimpleFeatureSource featureSource = wfs.getFeatureSource(service.getTypeName()); SimpleFeatureCollection features = featureSource.getFeatures(query); SimpleFeatureIterator iterator = features.features(); while (iterator.hasNext()) { SimpleFeature next = iterator.next(); Object attr = next.getAttribute(attribute); if (attr instanceof String) { String attrVal = (String) attr; domain.add(attrVal); } else { throw new UnsupportedOperationException("Currently only string attributes are allowed"); } } } finally { wfs.dispose(); } return domain; } WFSGetDomain(); Set<String> getDomainValuesAsStrings(WFSService service, String attribute);  }
@Test @Ignore public void testGetDomainValuesAsStrings() throws Exception { WFSService service = new WFSService(); service.setEndpoint("https: service.setTypeName("proxied:MauiK_shorelines"); WFSGetDomain instance = new WFSGetDomain(); Set<String> result = instance.getDomainValuesAsStrings(service, "DATE_"); assertThat(19, is(equalTo(result.size()))); }