WFS_1_1_0_DataStore implements WFSDataStore { public SimpleFeatureType getSchema(final String prefixedTypeName) throws IOException { SimpleFeatureType ftype = byTypeNameTypes.get(prefixedTypeName); if (ftype == null) { final QName featureDescriptorName; try { featureDescriptorName = wfs.getFeatureTypeName(prefixedTypeName); } catch (IllegalArgumentException e) { throw new SchemaNotFoundException(prefixedTypeName); } final SimpleFeatureType featureType; CoordinateReferenceSystem crs = getFeatureTypeCRS(prefixedTypeName); featureType = wfs.issueDescribeFeatureTypeGET(prefixedTypeName, crs); SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.init(featureType); builder.setName(prefixedTypeName); if (namespaceOverride != null) { builder.setNamespaceURI(namespaceOverride); } GeometryDescriptor defaultGeometry = featureType.getGeometryDescriptor(); if (defaultGeometry != null) { builder.setDefaultGeometry(defaultGeometry.getLocalName()); builder.setCRS(defaultGeometry.getCoordinateReferenceSystem()); } final SimpleFeatureType adaptedFeatureType = builder.buildFeatureType(); ftype = adaptedFeatureType; byTypeNameTypes.put(prefixedTypeName, ftype); } return ftype; } WFS_1_1_0_DataStore(final WFSProtocol wfs); void setMappedURIs(Map<String, String> mappedURIs); void setAxisOrder(String axisOrderOutput, String axisOrderFilter); String getAxisOrderForOutput(); String getAxisOrderForFilter(); void setNamespaceOverride(String namespaceOverride); void setMaxFeatures(Integer maxFeatures); Integer getMaxFeatures(); boolean isPreferPostOverGet(); void setPreferPostOverGet(Boolean booleanValue); WFSServiceInfo getInfo(); SimpleFeatureType getSchema(final String prefixedTypeName); SimpleFeatureType getSchema(Name name); List<Name> getNames(); String[] getTypeNames(); void dispose(); static boolean invertAxisNeeded(String axisOrder,
            CoordinateReferenceSystem crs); FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(Query query,
            final Transaction transaction); WFSFeatureSource getFeatureSource(final String typeName); LockingManager getLockingManager(); FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(String typeName,
            Filter filter, Transaction transaction); FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(String typeName,
            Transaction transaction); FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriterAppend(String typeName,
            Transaction transaction); SimpleFeatureSource getFeatureSource(Name typeName); void updateSchema(Name typeName, SimpleFeatureType featureType); void updateSchema(String typeName, SimpleFeatureType featureType); void createSchema(SimpleFeatureType featureType); QName getFeatureTypeName(String typeName); String getFeatureTypeTitle(String typeName); String getFeatureTypeAbstract(String typeName); ReferencedEnvelope getFeatureTypeWGS84Bounds(String typeName); ReferencedEnvelope getFeatureTypeBounds(String typeName); CoordinateReferenceSystem getFeatureTypeCRS(String typeName); Set<String> getFeatureTypeKeywords(String typeName); URL getDescribeFeatureTypeURL(String typeName); String getServiceAbstract(); Set<String> getServiceKeywords(); URI getServiceProviderUri(); URL getCapabilitiesURL(); String getServiceTitle(); String getServiceVersion(); ReferencedEnvelope getBounds(final Query query); int getCount(Query query); @Override String toString(); @Override void setUseDefaultSRS(Boolean useDefaultSRS); void setGetFeatureOutputFormat(String outputFormat); @Override void removeSchema(String typeName); @Override void removeSchema(Name typeName);  }
@Test public void testGetSchema() throws IOException { final InputStream schemaStream = TestData.openStream(this, CUBEWERX_GOVUNITCE.SCHEMA); TestHttpResponse httpResponse = new TestHttpResponse("", "UTF-8", schemaStream); TestHttpProtocol mockHttp = new TestHttpProtocol(httpResponse); createTestProtocol(CUBEWERX_GOVUNITCE.CAPABILITIES, mockHttp); URL describeUrl = TestData.getResource(this, CUBEWERX_GOVUNITCE.SCHEMA); wfs.setDescribeFeatureTypeURLOverride(describeUrl); WFS_1_1_0_DataStore ds = new WFS_1_1_0_DataStore(wfs); try { ds.getSchema("nonExistentTypeName"); fail("Expected SchemaNotFoundException"); } catch (SchemaNotFoundException e) { assertTrue(true); } SimpleFeatureType schema = ds.getSchema(CUBEWERX_GOVUNITCE.FEATURETYPENAME); assertNotNull(schema); }