GMLUtil { public static CoordinateReferenceSystem determineCollectionCRS(File file) throws IOException { InputStream inputStream = null; CoordinateReferenceSystem crs = null; try { inputStream = new BufferedInputStream(new FileInputStream(file)); crs = determineCollectionCRS(inputStream); } catch (FileNotFoundException ex) { throw new IOException(MSG_ERR_DETERMINE_CRS, ex); } finally { IOUtils.closeQuietly(inputStream); } return crs; }  static ReferencedEnvelope determineCollectionEnvelope(File file); static ReferencedEnvelope determineCollectionEnvelope(File file, CoordinateReferenceSystem crs); static ReferencedEnvelope determineCollectionEnvelope(InputStream inputStream, CoordinateReferenceSystem crs); static CoordinateReferenceSystem determineCollectionCRS(File file); static CoordinateReferenceSystem determineCollectionCRS(InputStream inputStream); static QName extractFeatureTypeSchema(File file); static QName extractFeatureTypeSchema(InputStream inputStream); static Configuration generateGMLConfiguration(File file); static Configuration generateGMLConfiguration(InputStream inputStream);  }
@Test public void testExtractCRSFromBoundedByNodeFromArcGISExampleFile() throws IOException { System.out.println("testExtractCRSAgainstArcGISExampleUsingFile"); File file = arcGis; CoordinateReferenceSystem result = GMLUtil.determineCollectionCRS(file); assertNotNull(result); assertEquals(2, result.getCoordinateSystem().getDimension()); assertEquals("World between 85°S and 85°N.", result.getDomainOfValidity().getDescription().toString()); assertEquals("EPSG:3857", result.getIdentifiers().toArray()[0].toString()); }
@Test public void testExtractCRSUsingMissingFile() { System.out.println("testExtractCRSUsingMissingFile"); File file = new File(FileUtils.getTempDirectory(), "I_do_not_exist"); try { GMLUtil.determineCollectionCRS(file); } catch (IOException ex) { assertThat(ex, instanceOf(IOException.class)); assertThat(ex.getCause(), instanceOf(FileNotFoundException.class)); } }
@Test public void testExtractCRSFromBoundedByNodeFromConusStatesExampleFile() throws IOException { System.out.println("testExtractCRSAgainstConusStatesExampleUsingFile"); File file = conusStates; CoordinateReferenceSystem result = GMLUtil.determineCollectionCRS(file); assertNull(result); }