EmfAppSchemaReader extends EmfComplexFeatureReader { public static Configuration findGmlConfiguration(AppSchemaConfiguration configuration) { SchemaIndex index = null; try { index = Schemas.findSchemas(configuration); for (QName name : SUPPORTED_GML_KNOWN_TYPE_TO_CONFIGURATION_MAP.keySet()) { XSDTypeDefinition type = index.getTypeDefinition(name); if (type != null) { try { return SUPPORTED_GML_KNOWN_TYPE_TO_CONFIGURATION_MAP.get(name) .newInstance(); } catch (Exception e) { throw new RuntimeException(e); } } } for (XSDSchema schema : index.getSchemas()) { String ns = schema.getTargetNamespace(); if (ns != null && ns.startsWith("http: throw new RuntimeException("Unsupported GML version for schema at " + configuration.getSchemaLocation()); } } } finally { if (index != null) { index.destroy(); } } return null; } private  EmfAppSchemaReader(); static EmfAppSchemaReader newInstance(); static Configuration findGmlConfiguration(AppSchemaConfiguration configuration);  }
@Test public void findGml31Configuration() { AppSchemaConfiguration configuration = new AppSchemaConfiguration( "urn:cgi:xmlns:CGI:GeoSciML:2.0", "http: Configuration gmlConfiguration = EmfAppSchemaReader.findGmlConfiguration(configuration); Assert.assertNotNull(gmlConfiguration); Assert.assertEquals(new GMLConfiguration(), gmlConfiguration); }
@Test public void findGml32Configuration() { AppSchemaConfiguration configuration = new AppSchemaConfiguration( "urn:cgi:xmlns:CGI:GeoSciML-Core:3.0.0", "https: new SchemaResolver()); Configuration gmlConfiguration = EmfAppSchemaReader.findGmlConfiguration(configuration); Assert.assertNotNull(gmlConfiguration); Assert.assertEquals(new org.geotools.gml3.v3_2.GMLConfiguration(), gmlConfiguration); }
@Test public void testNonGMLConfiguration() { SchemaCatalog catalog = SchemaCatalog.build(getClass() .getResource("/test-data/mappedPolygons.oasis.xml")); AppSchemaConfiguration configuration = new AppSchemaConfiguration( "http: "http: new SchemaResolver(catalog)); Configuration gmlConfiguration = EmfAppSchemaReader .findGmlConfiguration(configuration); Assert.assertNull(gmlConfiguration); }